Example #1
0
 public static OMElement xmlObjectToOMElement(XmlObject responseXmlObj) throws XMLStreamException {
   String responseXml;
   XmlOptions opts = new XmlOptions();
   opts.setSaveOuter();
   responseXml = responseXmlObj.xmlText(opts);
   OMElement outgoingMsg =
       org.apache.airavata.commons.WorkFlowUtils.reader2OMElement(new StringReader(responseXml));
   return outgoingMsg;
 }
  @Test
  public void testRestart() throws Exception {
    Subscription subscription = null;

    MessageBoxCreateThread thread = new MessageBoxCreateThread(BROKER_URL, MESSAGEBOX_URL, TOPIC);
    thread.start();

    Thread.sleep(100);
    thread.stop();

    Thread.sleep(5000);

    System.out.println("bringing down the Puller\n Publishing Messages");
    WseMsgBrokerClient client = new WseMsgBrokerClient();
    client.init(BROKER_URL);

    OMElement msg =
        WorkFlowUtils.reader2OMElement(
            new StringReader(CommonUtils.WORKFLOW_INITIALIZED_NOTIFICATION));

    client.publish(TOPIC, msg);

    System.out.println("Messages published");
    System.out.println("Creating another puller");
    EndpointReference epr = thread.getWsaEndpointReference();
    String subscriptionID = thread.getSubscriptionID();
    String topic = thread.getTopic();
    System.out.println(epr);
    System.out.println(subscriptionID);

    subscription =
        LeadNotificationManager.startListeningToSavedSubscription(
            BROKER_URL,
            epr,
            subscriptionID,
            topic,
            null,
            new Callback() {

              public void deliverMessage(
                  String topic, NotificationType type, XmlObject messageObj) {

                System.out.println("Notification Received, notification of type:" + type);
                System.out.println("Topic[" + topic + "]");
                // assertEquals(type, NotificationType.WorkflowInitialized);
                wait = false;
              }
            },
            false);

    System.out.println(subscription.getMessageBoxEPR());

    while (wait) {
      Thread.sleep(1000);
    }
  }