How to sumbit the current ESB Message to a Topic/Queue? - Forum - Technology Partner - Progress Community

How to sumbit the current ESB Message to a Topic/Queue?

 Forum

How to sumbit the current ESB Message to a Topic/Queue?

  • Sonic ESB 8.0.1

    How to sumbit the current ESB Message to a Topic or Queue?

    I have a requirement to:

    - receive a message at a Web Serice,

    - validate the message,

    - Place the ESB Message on a Queue/Topic

    - Reply to the Sender

    Then:

    - Write a Process to accept messages from the Queue/Topic

    - Process them

    I have it mostly working except:

    I have used an Endpoint Step in the Process to submit the message to the Topic. Using the JMS Test Client I can see the Message arriving on the Topic,

    but execution of the Process stops at the Endpoint Step and no reply is sent to the Web Service Client. (If I take out the Endpoint Step the the right messages is returned to the Web Service Client).

    Is that what is expected? Do I need to write a Java Service Type to make a copy (Clone) the ESB Message and submit the Copy to the Topic?

    If so, can someone point me to samples for:

    - How to Clone an ESB Message? (is XQMessage.clone right?)

    - How to place the cloned message on a Topic Endpoint?

    Or what is the correct approach?

    Thanks

    Steve

  • Hi Steve,

    I'd add a fnaout step to "clone" the message.

    One branch of the fanout will then generete the reply to and the other branch will sen to the endpoint.

    hth

    Stefan

  • I have seen the same behavior when I used the endpoint step in itinerary in process. Xcbr / fan-out can be used. I used the xcbr.

  • Hello Stephen,

    With version 7.6.1 it had to be done with a custom java service.

    With version 8.0. they added a "Dispatch Step" that does exactly that. It takes a message from ESB, sends it to a queue/topic, waits for the reply (configurable timeout) and puts the message back in ESB. I didn't have time to test it yet, but you can read more about the dispatch step in these help documents:

    - Sonic® 8.0.1 Product Update Bulletin (801_update_bulletin.pdf)

    - Sonic Workbench: Development Tools (dev_tools.pdf)

    Regards,

  • That's great Jimmy. Did just what i wanted.

    Thanks

    Steve

  • Hi Jimmy

    I've been using the Dispatch service and I thought it was working fine. Now I'm a bit confused. Here's what I've got:

    - ESB Process_A

    - Is a Sonic Connect Web Service process:

    - Receives a Web Service message and validates it

    - Does a one-way Dispatch to Topic_1

    - Returns a Web Service response (acknowledgement) to the caller.

    - ESB Proces_B

    - Listens on Topic_1

    - Transforms the message payload

    - Uses Sonic Connect to deliver the message to a Web Service end point (WS2)

    I've had this working and thought everything was OK.

    Today I ran it without WS2 running and Process_A failed with an Exception/Fault that a connection was refused to WS2.

    I thouht that the use of the  one-way Dispatch service in Process_A would simply post the message on the topic and continue processing. I can't see how any Fault in Process_B would impact on Process_A.

    Is my undersatnding wrong?

    Thanks

    Steve

  • I didn't have the chance to use the dispatch service yet, but I'm interested to learn what's the deal with your issue, if someone else knows...

  • Hi Jimmy

    I might have been hasty. I've tested again and it seems to be working as I expected. Must have been some other problem causing the problem.

    Regards

    Steve

  • Hi Jimmy

    Now that I've had success with the Dispatch service I find that I want to add some custom processing at the time of the Dispatch. Can you point me to some sample code or a class I can use to do the Dispatch myself? I'm guessing that I'll have to write my own Dispatch service rather than just being able to plug in to the supplied one, but I'm hoping that they externalised the actual Dispatch class so I can just call it.

    Thanks

    Steve

  • Hello Stephen, I have attached the my own dispatcher service. To use it, you will have to create a new service type in Sonic Workbench. Then, add the parameters that you can see in the init method. Lastly, paste the code from my class in yours. I hope this helps.

  • Hi Stephen,

    Can you achieve the custom processing using message mapping? You can manipulate both the request and response including message parts, headers, etc.

    Thanks

    -Mahesh

  • Hi Jimmy

    Thanks for sharing your code. I finally got to the point in development where I want to use a custom Dispatch. Unfortunately, from your sample, I couldn't figure out what I need to do. I could see how to build up the JMS Producer, which was really great.

    I don't know how to send (all of) the current XQMessage to a Topic/Queue. I want to do exactly what the Dispatch Service does: Passes the current XQMessage on to a new ESB Endpoint.

    I just want to wrap some more function around the Dispatch. In the short term I can solve it by having a Java Service Type Step, then doing the Dispatch Step, but I'd rather do it all in one place.

    Thanks

    Steve

  • Hi Makesh

    I'm not sure what you mean by that. I use Mapping fairly extensively in our application but it doesn't serve what I want here.

    What I want to do is pass the XQMessage on to ESB Endpoint (Topic/Queue) in exactly the same way as the Dispatch Service does it, only I want to add a bit more function into the Service. In other words, I'd like to see either:

    - How the Dispatch Service works or

    - Be able to call the same process as the Sonic Dispatch Service from within my own Java Service Type, or

    - See how it was done prior to Version 8, which, I understand, introduced the Dispatch Service.

    Another Task I have is to be able to construct and send a new message to an ESB Endpoint (Topic/Queue). I have a message with all headers and parts persisted in a database and I need to reconstruct that into an XQMessage and Dispatch it to an ESB Endpoint. I looked at the new Continuation Service but:

    - I failed to understand the detail of how to apply Continuation from the documentation and samples and

    - It appears simpler to just reconstruct the XQMessage from the database and send it to an ESB Endpoint.

    I'm assuming that once I understand how to do the Dispatch task mentioned above I'll be able to see how to achieve the second task.

    Thanks

    Steve

  • Figured it out eventially....
    The XQDispatch API did the trick:
    To DIspatch a message in a Java Service Type:
    XQAddress ep =
    ctx.getAddressFactory().createEndpointAddress(esbEndpoint);
    // esbEndpoint is a string containing a Topic/Queue name
    XQMessage msg = (XQMessage) message.clone();
    XQEnvelope env =
    ctx.getEnvelopeFactory().createTargetedEnvelope(ep, msg);
    XQDispatch dsp = ctx.getDispatcher();
    dsp.dispatch(env);
    And to re-construct a message from the database and dispatch it:
    Just create an empty message with:
    XQMessage xqMessage =
    ctx.getMessageFactory().createMessage();
    // and populate it from the database with addHeader and addPart
    // you have to leave out headers that start with JMS (I think because the Dispatch populates them)
    // but you can leave in the one with JMS*
    then dispatch it in the same way.
    Hope that helps someone.
    Regards
    Steve