IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

Durable Subscriber not working

  • 1.  Durable Subscriber not working

    Posted Tue September 21, 2010 09:09 AM

    Hi,
    I am a novice in wM JMS. I was working in OpenMQ JMS provider (Sun Micro) and successfully implemented Pub-Sub with MessageListener there. I had two different client programs for Subscribing and Publishing and since if there are no subscribers present in the topic, the messages published would be thrown away, I ran the subscriber program and then ran the publisher program to publish my messages. After I publish, when I ran the subscriber again with the same subscriber name, I could see the messages.
    Now owing to some requirement change, I need to use the wM JMS provider. The configuration part has been done in the wM side and now when I run the subscriber from a remote machine to make a subscriber active on the topic, I dont see any subscriber in the admin console. I did not modify the code apart from the connectionfatory, topic lookup name and the JNDI lookup details. I do not get any connection error and it seems the JNDI lookup works fine.
    I am using session.createDurableSubscriber() method to create durable subscriber on the topic. I am setting a client ID too.

    I really dont know what the problem is and the solution for this. This is a bit urgent and your help would be appreciated.

    Subscriber Code Snippet
    [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/color][/size][/COLOR][/SIZE] [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/color][/size][/COLOR][/SIZE] LXKJMSDurableSubscriber {
    [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]private[/color][/size][/COLOR][/SIZE] [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/color][/size][/COLOR][/SIZE] TextListener [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]implements[/color][/size][/COLOR][/SIZE] MessageListener, ExceptionListener {
    [SIZE=2][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]

    public[/b][/color][/size][/COLOR][/SIZE] [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/color][/size][/COLOR][/SIZE] onMessage(Message message) {
    [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (message [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]instanceof[/color][/size][/COLOR][/SIZE][SIZE=2] TextMessage) {
    TextMessage msg = (TextMessage) message;

    [/size][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]try[/color][/size][/COLOR][/SIZE] {
    [SIZE=2][SIZE=2]

    System.[/size][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]out[/color][/size][/COLOR][/SIZE].println("SUBSCRIBER: Reading message: "[SIZE=2]

    +msg.getText());
    }
    [SIZE=2]

    } [/size][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]catch[/color][/size][/COLOR][/SIZE] (Exception e) {
    System.
    [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]out[/color][/size][/COLOR][/SIZE].println("Exception in onMessage(): "[SIZE=2]

    • e.toString());

    }
    }
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]

    public[/b][/color][/size][/COLOR][/SIZE] LXKJMSDurableSubscriber() {
    TopicConnectionFactory topicConnectionFactory =
    [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/color][/size][/COLOR][/SIZE];

    [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]try[/color][/size][/COLOR][/SIZE] {

    [SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]

    [/color][/size][/COLOR][/SIZE]topicConnectionFactory =
    LXKJMSUtilities.[I]getTopicConnectionFactory/i;
    topicConnection =
    topicConnectionFactory.createTopicConnection();
    topicConnection.setClientID(“durablesubscriber”);
    topicSession = topicConnection.createTopicSession([SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]false[/color][/size][/COLOR][/SIZE],
    Session.
    [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]AUTO_ACKNOWLEDGE[/color][/size][/COLOR][/SIZE]);
    topic = LXKJMSUtilities.getTopic(topicName, topicSession);
    }
    [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]catch[/color][/size][/COLOR][/SIZE] (Exception e) {
    System.
    [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]out[/color][/size][/COLOR][/SIZE].println("Connection problem: " + e.toString());
    [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/color][/size][/COLOR][/SIZE] (topicConnection != [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]null[/color][/size][/COLOR][/SIZE]) {
    [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]try[/color][/size][/COLOR][/SIZE] {
    topicConnection.close();
    }
    [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]catch[/color][/size][/COLOR][/SIZE][SIZE=2] (JMSException ee) {}
    }
    System.[I]exit/i;
    }

    }
    [B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]

    public[/b][/color][/size][/COLOR][/SIZE] [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/color][/size][/COLOR][/SIZE] startSubscriber() {
    [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]try[/color][/size][/COLOR][/SIZE] {
    System.
    [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]out[/color][/size][/COLOR][/SIZE].println(“Starting subscriber”);
    topicConnection.stop();
    topicSubscriber = topicSession.createDurableSubscriber(topic[SIZE=2],

    [/size]subscriber);
    [SIZE=2][SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]

    topicListener[/color][/size][/COLOR][/SIZE] = [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/color][/size][/COLOR][/SIZE] TextListener();
    topicSubscriber.setMessageListener(topicListener);
    topicConnection.start();

    } [SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]catch[/color][/size][/COLOR][/SIZE] (JMSException e) {
    System.
    [SIZE=2][COLOR=#0000c0][SIZE=2][COLOR=#0000c0]out[/color][/size][/COLOR][/SIZE].println("Exception occurred: " + e.toString());
    exitResult[SIZE=2] = 1;
    }

    }
    }
    [/size][/SIZE][/SIZE][/SIZE][/SIZE][/SIZE][/SIZE]


    #webMethods
    #Integration-Server-and-ESB
    #Broker-JMS
    #Universal-Messaging-Broker


  • 2.  RE: Durable Subscriber not working

    Posted Wed May 18, 2011 03:31 PM

    Do you want 2 clients to subscribe to the same topic/message?Or Do you want your subscriber to pick only the ones it requires?


    #Broker-JMS
    #webMethods
    #Universal-Messaging-Broker
    #Integration-Server-and-ESB