You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by yeahman <tn...@symcor.com> on 2009/02/25 19:33:41 UTC

Jms Consumer to Bean Components to Jms Producer

We need to use the jms:comsumer to consume the message and send it to the
bean component, this bean will do some sets of business and send it to the
provider to consume this message.  We need to add the replyDestinationName
property to jms:provider? what is this for? which queue it is supposed to
be.  We use this config, but it is not quiet working and we got the queue
channel overload it to give connection error 2099.

Jms config 

<jms:consumer service="edddstub:InMessage" 
   						targetService="edddstub:engineStubService"
              endpoint="jbi"
              destinationName="DDD.REQ.Q"
              connectionFactory="#connectionFactory" 
              transacted="jms"     
              concurrentConsumers="1"
              cacheLevel="3"
   />
   
   
   <jms:provider service="edddstub:jmsBulkOutService" 
              endpoint="bulkout"
              destinationName="DDD.BULK.RESP.Q"
              connectionFactory="#connectionFactory"
              replyDestinationName="DDD.BULK.RESP.Q"
              marshaler="#providerMarshaler"
   />
   
    <jms:provider service="edddstub:jmsNonBulkOutService" 
              endpoint="nonbulkout"
              destinationName="DDD.NON.BULK.RESP.Q"
              connectionFactory="#connectionFactory"  
              replyDestinationName="DDD.NON.BULK.RESP.Q"
              marshaler="#providerMarshaler"
   />

	 <bean id="providerMarshaler"
class="com.symcor.eddd.publisher.DefaultProviderMarshaler" />  
 

Bean Component config:
<bean:endpoint service="edddstub:engineStubService" endpoint="endpoint"
		bean="#engineStubJBI" />
		
	<bean id="engineStubJBI"
		class="com.symcor.eddd.publisher.enginestub.EngineStubJBI">
		<property name="handler" ref="handler" />
		<property name="exceptionHandler" ref="exceptionHandler" />
	</bean>

And the java code for the bean:

@Override
	public void processMessageExchange(MessageExchange exchange)
			throws ServiceException {
		try {
			NormalizedMessage message = exchange.getMessage("in");
			Source source = message.getContent();
			if (source instanceof StringSource){
				StringSource xmlSource = (StringSource) source;
				UoW uow = UoWMarshalUtil.unmarshallString(xmlSource.getText());
				UoW outUoW = handler.createOutUoW(uow);
				String outString = UoWMarshalUtil.marshallUoW(outUoW);
				Source outSource = new StringSource(outString);
				// create the out message, send to service locator
				NormalizedMessage outMessage = exchange.createMessage();
				outMessage.setContent(outSource);
				if (handler.isBulk(outUoW.getUoWContext().getServicesList())){
					logger.debug("Send result to JMS BULK RESPONSE Queue");
					jmsBulkOut.send(outMessage);
				} else {
					logger.debug("Send result to JMS Non BULK RESPONSE Queue");
					jmsNonBulkOut.send(outMessage);
				}
			
				exchange.setStatus(ExchangeStatus.DONE);
				channel.send(exchange);
				
			} else {
				throw new ServiceException("Invalid Message type, message is not xml");
			}
		} catch (Exception e){
			throw new ServiceException(e);
		}
	}

We are using the servicemix 3.3, Any suggestions.

-- 
View this message in context: http://www.nabble.com/Jms-Consumer-to-Bean-Components-to-Jms-Producer-tp22208877p22208877.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Jms Consumer to Bean Components to Jms Producer

Posted by yeahman <tn...@symcor.com>.
Thanks for your helpful reply.  So your suggestion is that we should we the
Camel or EIP to route the message from jmsIn => bean endpoint => either
camel or Eip => Jmsout.  Is this JmsOut need to set replyDestination back to
any queue?

Thanks
Tu

Gert Vanthienen wrote:
> 
> L.S.,
> 
> 
> I'm not sure what the jmsBulkout and jmsNonBulkOut refers to in your
> code snippet, but if you want to forward the incoming message from a
> bean endpoint, you need to create a new MessageExchange and send that
> to the second endpoint.  BTW, you should probably also take care to
> only process MessageExchanges with status ACTIVE in your
> onMessageExchange() method, if you are sending a new exchange to
> another endpoint, you'll
> 
> WE ARE COVERED THIS ONE.
> 
> Another option (probably easier to configure/maintain) would be to use
> your bean endpoint to handle an InOut exchange, the In message
> contains the original payload and the out message contains the
> modified payload.  You can then create a pipeline in Camel or EIP that
> does from queue -> bean endpoint -> content based router -> to queue.
> You could also move the processing done by the bean to Camel, if you
> prefer using less different JBI components.
> 
> DOES THE CONTENT BASED ROUTER WILL RESOLVE THE ISSUE OF REPLY DESTINATION?
> WE DON'T NEED TO PROVIDE REPLY DESTINATION WHEN WE USE THE EIP ROUTER.
> 
> Regarding the replyDestination, that could be used for an handling a
> request-reponse model over JMS.  However, with your use case, you'd
> have to be using a DestinationChooser because of the alternating reply
> destination, so either one of the previous solution will probably be
> easier to implement.
> 
> IF WE USE THE DESTINATIONCHOOSER, THE REPLYDESTINATION WILL POINT TO THE
> BEAN POINT, AM I ON THE RIGHT TRACK?
> 
> 
> Regards,
> 
> Gert Vanthienen
> ------------------------
> Open Source SOA: http://fusesource.com
> Blog: http://gertvanthienen.blogspot.com/
> 
> 
> 
> 2009/2/25 yeahman <tn...@symcor.com>:
>>
>> We need to use the jms:comsumer to consume the message and send it to the
>> bean component, this bean will do some sets of business and send it to
>> the
>> provider to consume this message.  We need to add the
>> replyDestinationName
>> property to jms:provider? what is this for? which queue it is supposed to
>> be.  We use this config, but it is not quiet working and we got the queue
>> channel overload it to give connection error 2099.
>>
>> Jms config
>>
>> <jms:consumer service="edddstub:InMessage"
>>                                              
>>  targetService="edddstub:engineStubService"
>>              endpoint="jbi"
>>              destinationName="DDD.REQ.Q"
>>              connectionFactory="#connectionFactory"
>>              transacted="jms"
>>              concurrentConsumers="1"
>>              cacheLevel="3"
>>   />
>>
>>
>>   <jms:provider service="edddstub:jmsBulkOutService"
>>              endpoint="bulkout"
>>              destinationName="DDD.BULK.RESP.Q"
>>              connectionFactory="#connectionFactory"
>>              replyDestinationName="DDD.BULK.RESP.Q"
>>              marshaler="#providerMarshaler"
>>   />
>>
>>    <jms:provider service="edddstub:jmsNonBulkOutService"
>>              endpoint="nonbulkout"
>>              destinationName="DDD.NON.BULK.RESP.Q"
>>              connectionFactory="#connectionFactory"
>>              replyDestinationName="DDD.NON.BULK.RESP.Q"
>>              marshaler="#providerMarshaler"
>>   />
>>
>>         <bean id="providerMarshaler"
>> class="com.symcor.eddd.publisher.DefaultProviderMarshaler" />
>>
>>
>> Bean Component config:
>> <bean:endpoint service="edddstub:engineStubService" endpoint="endpoint"
>>                bean="#engineStubJBI" />
>>
>>        <bean id="engineStubJBI"
>>              
>>  class="com.symcor.eddd.publisher.enginestub.EngineStubJBI">
>>                <property name="handler" ref="handler" />
>>                <property name="exceptionHandler" ref="exceptionHandler"
>> />
>>        </bean>
>>
>> And the java code for the bean:
>>
>> @Override
>>        public void processMessageExchange(MessageExchange exchange)
>>                        throws ServiceException {
>>                try {
>>                        NormalizedMessage message =
>> exchange.getMessage("in");
>>                        Source source = message.getContent();
>>                        if (source instanceof StringSource){
>>                                StringSource xmlSource = (StringSource)
>> source;
>>                                UoW uow =
>> UoWMarshalUtil.unmarshallString(xmlSource.getText());
>>                                UoW outUoW = handler.createOutUoW(uow);
>>                                String outString =
>> UoWMarshalUtil.marshallUoW(outUoW);
>>                                Source outSource = new
>> StringSource(outString);
>>                                // create the out message, send to service
>> locator
>>                                NormalizedMessage outMessage =
>> exchange.createMessage();
>>                                outMessage.setContent(outSource);
>>                                if
>> (handler.isBulk(outUoW.getUoWContext().getServicesList())){
>>                                        logger.debug("Send result to JMS
>> BULK RESPONSE Queue");
>>                                        jmsBulkOut.send(outMessage);
>>                                } else {
>>                                        logger.debug("Send result to JMS
>> Non BULK RESPONSE Queue");
>>                                        jmsNonBulkOut.send(outMessage);
>>                                }
>>
>>                                exchange.setStatus(ExchangeStatus.DONE);
>>                                channel.send(exchange);
>>
>>                        } else {
>>                                throw new ServiceException("Invalid
>> Message type, message is not xml");
>>                        }
>>                } catch (Exception e){
>>                        throw new ServiceException(e);
>>                }
>>        }
>>
>> We are using the servicemix 3.3, Any suggestions.
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Jms-Consumer-to-Bean-Components-to-Jms-Producer-tp22208877p22208877.html
>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>
>>
> 
> 
> -----
> ---
> Gert Vanthienen
> http://gertvanthienen.blogspot.com
> 

-- 
View this message in context: http://www.nabble.com/Jms-Consumer-to-Bean-Components-to-Jms-Producer-tp22208877p22339811.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Jms Consumer to Bean Components to Jms Producer

Posted by Gert Vanthienen <ge...@gmail.com>.
L.S.,


I'm not sure what the jmsBulkout and jmsNonBulkOut refers to in your
code snippet, but if you want to forward the incoming message from a
bean endpoint, you need to create a new MessageExchange and send that
to the second endpoint.  BTW, you should probably also take care to
only process MessageExchanges with status ACTIVE in your
onMessageExchange() method, if you are sending a new exchange to
another endpoint, you'll

Another option (probably easier to configure/maintain) would be to use
your bean endpoint to handle an InOut exchange, the In message
contains the original payload and the out message contains the
modified payload.  You can then create a pipeline in Camel or EIP that
does from queue -> bean endpoint -> content based router -> to queue.
You could also move the processing done by the bean to Camel, if you
prefer using less different JBI components.

Regarding the replyDestination, that could be used for an handling a
request-reponse model over JMS.  However, with your use case, you'd
have to be using a DestinationChooser because of the alternating reply
destination, so either one of the previous solution will probably be
easier to implement.


Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/2/25 yeahman <tn...@symcor.com>:
>
> We need to use the jms:comsumer to consume the message and send it to the
> bean component, this bean will do some sets of business and send it to the
> provider to consume this message.  We need to add the replyDestinationName
> property to jms:provider? what is this for? which queue it is supposed to
> be.  We use this config, but it is not quiet working and we got the queue
> channel overload it to give connection error 2099.
>
> Jms config
>
> <jms:consumer service="edddstub:InMessage"
>                                                targetService="edddstub:engineStubService"
>              endpoint="jbi"
>              destinationName="DDD.REQ.Q"
>              connectionFactory="#connectionFactory"
>              transacted="jms"
>              concurrentConsumers="1"
>              cacheLevel="3"
>   />
>
>
>   <jms:provider service="edddstub:jmsBulkOutService"
>              endpoint="bulkout"
>              destinationName="DDD.BULK.RESP.Q"
>              connectionFactory="#connectionFactory"
>              replyDestinationName="DDD.BULK.RESP.Q"
>              marshaler="#providerMarshaler"
>   />
>
>    <jms:provider service="edddstub:jmsNonBulkOutService"
>              endpoint="nonbulkout"
>              destinationName="DDD.NON.BULK.RESP.Q"
>              connectionFactory="#connectionFactory"
>              replyDestinationName="DDD.NON.BULK.RESP.Q"
>              marshaler="#providerMarshaler"
>   />
>
>         <bean id="providerMarshaler"
> class="com.symcor.eddd.publisher.DefaultProviderMarshaler" />
>
>
> Bean Component config:
> <bean:endpoint service="edddstub:engineStubService" endpoint="endpoint"
>                bean="#engineStubJBI" />
>
>        <bean id="engineStubJBI"
>                class="com.symcor.eddd.publisher.enginestub.EngineStubJBI">
>                <property name="handler" ref="handler" />
>                <property name="exceptionHandler" ref="exceptionHandler" />
>        </bean>
>
> And the java code for the bean:
>
> @Override
>        public void processMessageExchange(MessageExchange exchange)
>                        throws ServiceException {
>                try {
>                        NormalizedMessage message = exchange.getMessage("in");
>                        Source source = message.getContent();
>                        if (source instanceof StringSource){
>                                StringSource xmlSource = (StringSource) source;
>                                UoW uow = UoWMarshalUtil.unmarshallString(xmlSource.getText());
>                                UoW outUoW = handler.createOutUoW(uow);
>                                String outString = UoWMarshalUtil.marshallUoW(outUoW);
>                                Source outSource = new StringSource(outString);
>                                // create the out message, send to service locator
>                                NormalizedMessage outMessage = exchange.createMessage();
>                                outMessage.setContent(outSource);
>                                if (handler.isBulk(outUoW.getUoWContext().getServicesList())){
>                                        logger.debug("Send result to JMS BULK RESPONSE Queue");
>                                        jmsBulkOut.send(outMessage);
>                                } else {
>                                        logger.debug("Send result to JMS Non BULK RESPONSE Queue");
>                                        jmsNonBulkOut.send(outMessage);
>                                }
>
>                                exchange.setStatus(ExchangeStatus.DONE);
>                                channel.send(exchange);
>
>                        } else {
>                                throw new ServiceException("Invalid Message type, message is not xml");
>                        }
>                } catch (Exception e){
>                        throw new ServiceException(e);
>                }
>        }
>
> We are using the servicemix 3.3, Any suggestions.
>
> --
> View this message in context: http://www.nabble.com/Jms-Consumer-to-Bean-Components-to-Jms-Producer-tp22208877p22208877.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>