(WMB) Publisher Subscriber in WMB 7.0

Publish/Subscribe architecture is useful in scenarios where P2P might not be suitable, reasons are obvious :

  • Problems with large numbers of senders & receivers.
  • Problems when senders & receivers change frequently; (Becomes unmanageable)
How it works in WMB 7.0
  • MQ based subscription messages registered using a special queue SYSTEM.BROKER.CONTROL.QUEUE.
  • Do not need to define a queue to handle subscription requests.
  • Publication messages handled within the flow.
  • Publication node receives publication messages and distributes to the subscribers matching the topic within the publication message.
Subscriber Flow

MQINPUT ->>  COMPUTE ->> MQOUTPUT (SYSTEM.BROKER.CONTROL.QUEUE)

Code for Compute Node :

                    CALL CopyEntireMessage();
                         SET OutputRoot.MQRFH2.psc.Command = 'RegSub'; --RegSub is a keyword
                         SET OutputRoot.MQRFH2.psc.Topic = 'SPORTS';  --TopicName
                         SET OutputRoot.MQRFH2.psc.QName = 'DATA';  -- QueueName
                         SET OutputRoot.MQRFH2.psc.QMgrName = 'QM';  -- QueueManagerName
                         Declare PTR REFERENCE to OutputRoot.MQRFH2;
                         Detach PTR;
                         attach PTR TO OutputRoot.MQMD AS NEXTSIBLING ;


 Publisher Flow

MQINPUT ->> COMPUTE ->> PUBLICATION NODE

Code for Compute Node :

                    CALL CopyEntireMessage();
                         SET OutputRoot.MQRFH2.psc.Command = 'Publish'; -- Publish is a keyword
                         SET OutputRoot.MQRFH2.psc.Topic = 'SPORTS'; --TopicName
                         Declare PTR REFERENCE to OutputRoot.MQRFH2;
                         Detach PTR;
                         attach PTR TO OutputRoot.MQMD AS NEXTSIBLING ;
                         RETURN TRUE;
OR





Exception Scenario :

While subscribing, we may get following warning :



And no subscription happens. I solved this issue by having the logged user name less then 12 chars, we can also see : http://www.mqseries.net/phpBB2/viewtopic.php?t=1056&highlight=2035+sid

18 comments:

  1. Hi Harish,
    Thanks for publishing this topic on your blog !
    After publishing a message in the input queue 'PUB.IN', I assume the message gets published in the topic 'SPORTS'. How does the subscriber flow pick the message from the topic ? Is there any configuration that has to be done in the Message broker Explorer ?

    ReplyDelete
  2. Also, Do I need to create a queue called 'STARTER' for the subscriber flow ? If so what is the input for this ?

    ReplyDelete
  3. Hey Shiva, First of all you have to subscribe to a particular topic, in the given example it is "SPORTS" , so you need to trigger this(Subscriber) flow with any input (Idea is to subscribe it that all). Once you do this then trigger the Publisher flow, you will get whatever been posted in PUB.IN queue into "DATA" queue.

    See this:
    SET OutputRoot.MQRFH2.psc.QName = 'DATA'; -- QueueName

    Hoping this would be useful for you...

    ReplyDelete
  4. Thanks for your reply Harish.
    I've got one more question regarding guaranteed delivery to the subscribers.
    Suppose I have a topic: Stocks_abc
    Subscribers: Queue1 and Queue2
    Scene 1: Both queues are up - When I put a message on the topic, both the queues receives the message.
    Scene 2: If Queue1 is down and Queue2 is up - When I put a message on the topic, only Queue2 receives the message. Later when I bring Queue1 up, my requirement is it should receive the message or I should be notified it didn't reach the queue.
    Any idea on this ??

    ReplyDelete
  5. Hi Harish
     
    Thank you for a good and very needed blog. I have been investigating reg. the same concept since couple of weeks. There are very few blogs out there on WMB 7.0 pub/sub. This fits my need perfectly. I would greatly appreciate if you can answer my below questions.
     
    1.       May I know which version of WMQ you are using here. Does these message flows work with WMQ 7.0 and WMB 7.0?
    2.       Does Subscriber flow in this blog create an entry in WMQ Subscriptions ? If not what does it do. Before triggering the publication flow, I want to confirm that the subscription has been happened successfully. How can I do this.
    3.       I also have a need to create a topic in the message flow. Is it possible. If so, can you please describe the flow in detail.
     
    Thank You again for very good and detailed blog.

    ReplyDelete
  6. Hi Harish

    I would greatly appreciate if you can answer above 3 questions ASAP. Thank You again.

    ReplyDelete
  7. Hi Hyndhavi,

    Please find my comments:

    1. May I know which version of WMQ you are using here. Does these message flows work with WMQ 7.0 and WMB 7.0?
    [Harish] : It is 7.0 & yes it will work.

    2. Does Subscriber flow in this blog create an entry in WMQ Subscriptions ? If not what does it do. Before triggering the publication flow, I want to confirm that the subscription has been happened successfully. How can I do this.
    [Harish] : Yes it creates subscription in WMQ.
    Steps to see the subscription :
    a) Open MQ 7.0.. & see subscriptions under queue Manager tab.
    b) You can see Subscription name, Topic name, Topic string etc.
    c) Topic string is "SPORTS" as I have used in above example.

    3. I also have a need to create a topic in the message flow. Is it possible. If so, can you please describe the flow in detail.
    [Harish] : On basis of my little knowledge on WMB, I do not think you can create a topic in flow, topics are subject to be configured in MQ.

    ReplyDelete
  8. Hi
    Presently we are using wmb v6.1 pub-sub is at broker level, in our one of application subscriber is not able to receive messages.
    Publish flow executed successfully. How to find in this case if flow is subscribed successfully or not.

    ReplyDelete
  9. It 's an amazing and awsome blog Thanks for sharing
    Oracle SOA Online Training

    ReplyDelete
  10. The post was engaging, informative, and well-written. The author did an excellent job of breaking down a complex topic into easily digestible and understandable sections. The writing style was clear and concise, which made it easy to follow along and stay engaged throughout. If you are searching Android app development company in india which can give you fast delivery on app development then you are reading the right comment.

    ReplyDelete
  11. Elevate your email marketing with our expert Mailwizz services. Unlock efficient campaigns and superior deliverability today.

    ReplyDelete
  12. Optimize your website with expert CPanel Server Management solutions. Ensure smooth performance and security with our services.

    ReplyDelete
  13. How to Sign Up for YouTube with a Brazil Virtual Number from PVApins (2024): You can create a YouTube account using any email provider (e.g., Hotmail) without needing Gmail. During signup, choose "Create an account for yourself" and use your existing email. For phone verification, visit PVApins.com, add $1.60 to your balance, and purchase a Brazil virtual number. Use this number on YouTube during registration, then retrieve the verification code from PVApins. Enter the code on YouTube to complete the process.

    visit us : https://pvapins.com/?/EN

    ReplyDelete