You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Mick Knutson <mi...@gmail.com> on 2008/08/28 22:30:03 UTC
Trying to use a jsr181 service to create a NormalizedMessage to a jms endpoint
I am going through the loan broker example, and am having trouble
understanding how to create a new message based on my soap input.
I have this:
* private void createChangeRequest(MessageExchange exchange) throws
MessagingException {
if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
log.info("Receiving Change Request");
// Create aggregation
String id = exchange.getExchangeId();
ChangeRequest changeRequest = new ChangeRequest();
changeRequest.request = exchange;
changeRequest.changeRequestId = (Long) getInProperty(exchange,
Constants.PROPERTY_CHANGE_REQUEST_ID);
changeRequest.quota = (Double) getInProperty(exchange,
Constants.PROPERTY_QUOTA);
changeRequests.put(id, changeRequest);
InOut inout = createInOutExchange(new
QName(Constants.CHANGE_REQUEST_NS,
Constants.CREDITAGENCY_SERVICE), null, null);
inout.setProperty(Constants.PROPERTY_CORRELATIONID, id);
NormalizedMessage normalizedMessage = inout.createMessage();
normalizedMessage.setProperty(Constants.PROPERTY_CHANGE_REQUEST_ID,
changeRequest.changeRequestId);
inout.setInMessage(normalizedMessage);
send(inout);
}
}
*
But I do not know how I am to get the MessageExchange I need.
---
Thank You…
Mick Knutson
BASE Logic, inc.
(415) 354-4215
Website: http://baselogic.com
Blog: http://baselogic.com/blog
BLiNC Magazine: http://blincmagazine.com
Linked IN: http://linkedin.com/in/mickknutson
DJ Mick: http://djmick.com
MySpace: http://myspace.com/mickknutson
Vacation Rental: http://tahoe.baselogic.com
Re: Trying to use a jsr181 service to create a NormalizedMessage
to a jms endpoint
Posted by Gert Vanthienen <ge...@skynet.be>.
Mick,
Looking at the code below, I see two problems:
- Do you somehow handle the original exchange? I don't see any code
that either sends a response (for an InOut exchange) or a DONE (for an
InOnly).
- With the new InOut MessageExchange you just created, you do a send().
This means the MessageExchange will be sent asynchronously. Your code
will just continue and your component will get another callback when
this MessageExchange has been answered. If you want to wait for the
response to become available in this block of code directly, you have to
use sendSync() instead. However, if you can implement it with
asynchronous messaging as you're doing now, this will greatly improve
scalability for your application because you don't have any threads that
are doing nothing -- just waiting for a reponse.
Regards,
Gert
Mick Knutson wrote:
> I am going through the loan broker example, and am having trouble
> understanding how to create a new message based on my soap input.
>
> I have this:
> * private void createChangeRequest(MessageExchange exchange) throws
> MessagingException {
> if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
> log.info("Receiving Change Request");
>
> // Create aggregation
> String id = exchange.getExchangeId();
> ChangeRequest changeRequest = new ChangeRequest();
> changeRequest.request = exchange;
> changeRequest.changeRequestId = (Long) getInProperty(exchange,
> Constants.PROPERTY_CHANGE_REQUEST_ID);
> changeRequest.quota = (Double) getInProperty(exchange,
> Constants.PROPERTY_QUOTA);
>
> changeRequests.put(id, changeRequest);
>
> InOut inout = createInOutExchange(new
> QName(Constants.CHANGE_REQUEST_NS,
> Constants.CREDITAGENCY_SERVICE), null, null);
> inout.setProperty(Constants.PROPERTY_CORRELATIONID, id);
>
> NormalizedMessage normalizedMessage = inout.createMessage();
>
> normalizedMessage.setProperty(Constants.PROPERTY_CHANGE_REQUEST_ID,
> changeRequest.changeRequestId);
> inout.setInMessage(normalizedMessage);
> send(inout);
> }
> }
> *
>
> But I do not know how I am to get the MessageExchange I need.
>
> ---
> Thank You…
>
> Mick Knutson
> BASE Logic, inc.
> (415) 354-4215
>
> Website: http://baselogic.com
> Blog: http://baselogic.com/blog
> BLiNC Magazine: http://blincmagazine.com
> Linked IN: http://linkedin.com/in/mickknutson
> DJ Mick: http://djmick.com
> MySpace: http://myspace.com/mickknutson
> Vacation Rental: http://tahoe.baselogic.com
>
>