You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by "Raj@nih" <yr...@gmail.com> on 2007/10/03 19:44:15 UTC

Regarding servicemix bean and jms-consumer

Hi,
I made an SA successfully using the servicemix-bean su and  jms-consumer su
and used mvn command   
to make SA out of them and build was successful.I wrote a client jms program
that sends the message.But I couldn't get response back from bean I am using
simple inout echo bean that you listed on the site.
I think problem is with my xbean and target point 
i am sending both here.


beans xmlns:bean="http://servicemix.apache.org/bean/1.0"
       xmlns:y="http://localhost:8192/yrkproject">

  <bean:endpoint service="y:service"
endpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectinput"
bean="#myBean"/>

  <bean id="myBean" class="org.apache.YrkProject.MyBean"/>
</beans>

beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
       xmlns:y="http://localhost:8192/yrkproject"
       xmlns:amq="http://activemq.org/config/1.0">

    
    <jms:endpoint service="y:yrkproject"
                 
endpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
                  targetService="y:yrkproject"
                 
targetEndpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
                  role="consumer" 
                  destinationStyle="queue"
                 
jmsProviderDestinationName="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
                  defaultOperation="test:Echo"
                  connectionFactory="#connectionFactory" />
     <bean id="#connectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL" value="tcp://localhost:61616"/>
            </bean>
        </property>          
    </bean>               
   

    

</beans>



This is my client 

package nih.nci.gov.caXchange;
import javax.jbi.messaging.InOut;
import org.apache.servicemix.client.DefaultServiceMixClient; 
import org.apache.servicemix.jbi.jaxp.StringSource;
import javax.xml.namespace.QName; 
import javax.jms.*;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.command.ActiveMQQueue;


public class TestJmsClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws JMSException{
		 System.out.println("Connecting to JMS server.");
		  // ActiveMQ JMS Provider code
        ActiveMQConnectionFactory factory =                         
            new ActiveMQConnectionFactory("tcp://localhost:61616"); 
        Destination inQueue = new
ActiveMQQueue("nih.nci.gov.caXchange.org.servicemix.yrkprojectsource");
        Destination outQueue = new
ActiveMQQueue("nih.nci.gov.caXchange.org.servicemix.yrkprojectoutput");
        Connection connection = factory.createConnection();         
        Session session = connection.createSession(false,
Session.CLIENT_ACKNOWLEDGE);
     // Create the message 66 and consumer
        MessageProducer producer = session.createProducer(inQueue);  
        System.out.println("Producer got this:  "+producer);
        MessageConsumer consumer = session.createConsumer(outQueue);
        System.out.println("Consumer got this:   "+consumer);
        connection.start();  
        System.out.println("Sending request.");                     
        //producer.send(session.createTextMessage("<message>Hello,
world!</message>"));
        TextMessage tMsg = session.createTextMessage("Yogi");
        System.out.println(tMsg);
        tMsg.setJMSReplyTo(inQueue);
        producer.send(tMsg);
        connection.close();
        System.out.println("Done.");
        
        
        
		
	}
	
	  /*public void init(ComponentContext context) throws JBIException {
          this.context = context;
          context.activateEndpoint(new QName("http://your.namespace",
"service"), "endpoint");
  }*/ 
	
	/*public void testEcho() throws Exception {
		DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
		InOut me = client.createInOutExchange();
		me.setService(new QName("http://bpmscript.org/jbi", "timeout"));
		me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
		ssertTrue(client.sendSync(me, 1000000));
		Exception error = me.getError();
		assertTrue(error instanceof TimeoutException);
				} */

}


Can any one suggest me how do I get reply back from servicemix bean.
Regards,
Raj
-- 
View this message in context: http://www.nabble.com/Regarding-servicemix-bean-and-jms-consumer-tf4563322s12049.html#a13024104
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Regarding servicemix bean and jms-consumer

Posted by Bruce Snyder <br...@gmail.com>.
On 10/5/07, Raj@nih <yr...@gmail.com> wrote:

>     public void onMessageExchange(MessageExchange exchange) throws
> MessagingException {
           System.out.println("EXCHANGE: " + exchange);

>         if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
>             MessageUtil.transferInToOut(exchange, exchange);
>             channel.send(exchange);
>         }

Well for starters, I highly suggest adding the call to println()
above. This will tell you if the onMessageExchange() method is even
getting the exchange.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/
Castor - http://castor.org/

Re: Regarding servicemix bean and jms-consumer

Posted by "Raj@nih" <yr...@gmail.com>.
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.servicemix.yrkproject;

import org.apache.servicemix.MessageExchangeListener;
import org.apache.servicemix.jbi.util.MessageUtil;

import javax.annotation.Resource;
import javax.jbi.messaging.DeliveryChannel;
import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;

import javax.jbi.component.*;

public class MyBean implements MessageExchangeListener {
	private ComponentContext context; 

    @Resource
    private DeliveryChannel channel;
    public void onMessageExchange(MessageExchange exchange) throws
MessagingException {
    	if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
            MessageUtil.transferInToOut(exchange, exchange);
            channel.send(exchange);
        }
    	
    	
}
    public void setContext(javax.jbi.component.ComponentContext context) {
        this.context = context;
} 

}


bsnyder wrote:
> 
> On 10/5/07, Raj@nih <yr...@gmail.com> wrote:
>>
>> hi,
>> thanks for the suggestion
>> so you want me to build SA again
>> i am bit confused about the jms1 and jsm2
>> are they consumer or producer or both
>> also how does the xbean code of eip look like
>> also what will be the targets of the flow in this case from where to
>> where
> 
> The jms1-su is a consumer of queueA and the jms2-su is a provider to
> queueB (simply for checking to see if the message is received.
> 
> Can you post the body of the
> org.apache.YrkProject.MyBean.onMessageExchange() method?
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> Apache ActiveMQ - http://activemq.org/
> Apache ServiceMix - http://servicemix.org/
> Apache Geronimo - http://geronimo.apache.org/
> Castor - http://castor.org/
> 
> 

-- 
View this message in context: http://www.nabble.com/Regarding-servicemix-bean-and-jms-consumer-tf4563322s12049.html#a13063331
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Regarding servicemix bean and jms-consumer

Posted by Bruce Snyder <br...@gmail.com>.
On 10/5/07, Raj@nih <yr...@gmail.com> wrote:
>
> hi,
> thanks for the suggestion
> so you want me to build SA again
> i am bit confused about the jms1 and jsm2
> are they consumer or producer or both
> also how does the xbean code of eip look like
> also what will be the targets of the flow in this case from where to where

The jms1-su is a consumer of queueA and the jms2-su is a provider to
queueB (simply for checking to see if the message is received.

Can you post the body of the
org.apache.YrkProject.MyBean.onMessageExchange() method?

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/
Castor - http://castor.org/

Re: Regarding servicemix bean and jms-consumer

Posted by "Raj@nih" <yr...@gmail.com>.
hi,
thanks for the suggestion 
so you want me to build SA again 
i am bit confused about the jms1 and jsm2 
are they consumer or producer or both 
also how does the xbean code of eip look like 
also what will be the targets of the flow in this case from where to where 
Regards,
Raj

bsnyder wrote:
> 
> On 10/4/07, Raj@nih <yr...@gmail.com> wrote:
>>
>> Thanks you very much bruce it worked
>> the only mistake was target and some package name.
>> Can you tell me how do i trace all the flow in eclipse
>> the control is not going to bean method
> 
> I suggest putting a EIP wiretap between the JMS SU and the bean SU:
> 
> http://incubator.apache.org/servicemix/servicemix-eip.html#servicemix-eip-WireTap
> 
> You'll need to tell the wiretap to send the message somewhere. Using a
> different JMS queue is good idea because you can then view the enqueue
> count and browse the messages on the queue via jconsole before it gets
> to the bean SU. This would make the flow steps look like this:
> 
> 1) jms1-su (queueA)
> 2) eip-wiretap-su
> 3a) jms2-su (queueB)
> 3b) bean-su
> 
> Then you can use jconsole to look at queueB to view the enqueue count
> and to browse the messages.
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> Apache ActiveMQ - http://activemq.org/
> Apache ServiceMix - http://servicemix.org/
> Apache Geronimo - http://geronimo.apache.org/
> Castor - http://castor.org/
> 
> 

-- 
View this message in context: http://www.nabble.com/Regarding-servicemix-bean-and-jms-consumer-tf4563322s12049.html#a13058759
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Regarding servicemix bean and jms-consumer

Posted by Bruce Snyder <br...@gmail.com>.
On 10/4/07, Raj@nih <yr...@gmail.com> wrote:
>
> Thanks you very much bruce it worked
> the only mistake was target and some package name.
> Can you tell me how do i trace all the flow in eclipse
> the control is not going to bean method

I suggest putting a EIP wiretap between the JMS SU and the bean SU:

http://incubator.apache.org/servicemix/servicemix-eip.html#servicemix-eip-WireTap

You'll need to tell the wiretap to send the message somewhere. Using a
different JMS queue is good idea because you can then view the enqueue
count and browse the messages on the queue via jconsole before it gets
to the bean SU. This would make the flow steps look like this:

1) jms1-su (queueA)
2) eip-wiretap-su
3a) jms2-su (queueB)
3b) bean-su

Then you can use jconsole to look at queueB to view the enqueue count
and to browse the messages.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/
Castor - http://castor.org/

Re: Regarding servicemix bean and jms-consumer

Posted by "Raj@nih" <yr...@gmail.com>.
Thanks you very much bruce it worked 
the only mistake was target and some package name.
Can you tell me how do i trace all the flow in eclipse 
the control is not going to bean method
Regards,
Yogaraj

Raj@nih wrote:
> 
> Hi,
> I made an SA successfully using the servicemix-bean su and  jms-consumer
> su and used mvn command   
> to make SA out of them and build was successful.I wrote a client jms
> program that sends the message.But I couldn't get response back from bean
> I am using simple inout echo bean that you listed on the site.
> I think problem is with my xbean and target point 
> i am sending both here.
> 
> 
> beans xmlns:bean="http://servicemix.apache.org/bean/1.0"
>        xmlns:y="http://localhost:8192/yrkproject">
> 
>   <bean:endpoint service="y:service"
> endpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectinput"
> bean="#myBean"/>
> 
>   <bean id="myBean" class="org.apache.YrkProject.MyBean"/>
> </beans>
> 
> beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
>        xmlns:y="http://localhost:8192/yrkproject"
>        xmlns:amq="http://activemq.org/config/1.0">
> 
>     
>     <jms:endpoint service="y:yrkproject"
>                  
> endpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
>                   targetService="y:yrkproject"
>                  
> targetEndpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
>                   role="consumer" 
>                   destinationStyle="queue"
>                  
> jmsProviderDestinationName="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
>                   defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>                   defaultOperation="test:Echo"
>                   connectionFactory="#connectionFactory" />
>      <bean id="#connectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
>         <property name="connectionFactory">
>             <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>                 <property name="brokerURL" value="tcp://localhost:61616"/>
>             </bean>
>         </property>          
>     </bean>               
>    
> 
>     
> 
> </beans>
> 
> 
> 
> This is my client 
> 
> package nih.nci.gov.caXchange;
> import javax.jbi.messaging.InOut;
> import org.apache.servicemix.client.DefaultServiceMixClient; 
> import org.apache.servicemix.jbi.jaxp.StringSource;
> import javax.xml.namespace.QName; 
> import javax.jms.*;
> 
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.apache.activemq.command.ActiveMQQueue;
> 
> 
> public class TestJmsClient {
> 
> 	/**
> 	 * @param args
> 	 */
> 	public static void main(String[] args) throws JMSException{
> 		 System.out.println("Connecting to JMS server.");
> 		  // ActiveMQ JMS Provider code
>         ActiveMQConnectionFactory factory =                         
>             new ActiveMQConnectionFactory("tcp://localhost:61616"); 
>         Destination inQueue = new
> ActiveMQQueue("nih.nci.gov.caXchange.org.servicemix.yrkprojectsource");
>         Destination outQueue = new
> ActiveMQQueue("nih.nci.gov.caXchange.org.servicemix.yrkprojectoutput");
>         Connection connection = factory.createConnection();         
>         Session session = connection.createSession(false,
> Session.CLIENT_ACKNOWLEDGE);
>      // Create the message 66 and consumer
>         MessageProducer producer = session.createProducer(inQueue);  
>         System.out.println("Producer got this:  "+producer);
>         MessageConsumer consumer = session.createConsumer(outQueue);
>         System.out.println("Consumer got this:   "+consumer);
>         connection.start();  
>         System.out.println("Sending request.");                     
>         //producer.send(session.createTextMessage("<message>Hello,
> world!</message>"));
>         TextMessage tMsg = session.createTextMessage("Yogi");
>         System.out.println(tMsg);
>         tMsg.setJMSReplyTo(inQueue);
>         producer.send(tMsg);
>         connection.close();
>         System.out.println("Done.");
>         
>         
>         
> 		
> 	}
> 	
> 	  /*public void init(ComponentContext context) throws JBIException {
>           this.context = context;
>           context.activateEndpoint(new QName("http://your.namespace",
> "service"), "endpoint");
>   }*/ 
> 	
> 	/*public void testEcho() throws Exception {
> 		DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
> 		InOut me = client.createInOutExchange();
> 		me.setService(new QName("http://bpmscript.org/jbi", "timeout"));
> 		me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
> 		ssertTrue(client.sendSync(me, 1000000));
> 		Exception error = me.getError();
> 		assertTrue(error instanceof TimeoutException);
> 				} */
> 
> }
> 
> 
> Can any one suggest me how do I get reply back from servicemix bean.
> Regards,
> Raj
> 

-- 
View this message in context: http://www.nabble.com/Regarding-servicemix-bean-and-jms-consumer-tf4563322s12049.html#a13040011
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Regarding servicemix bean and jms-consumer

Posted by "Raj@nih" <yr...@gmail.com>.
Hi Bruce,
Thanks  for the prompt reply 
Now I am setting my target service of jms to the bean service still its not
working 
I am expecting actually the echo of my message that i am sending to the
jms-queue.


This is my jms-client test console of the output
Connecting to JMS server.
log4j:WARN No appenders could be found for logger
(org.apache.activemq.transport.WireFormatNegotiator).
log4j:WARN Please initialize the log4j system properly.
Producer got this:  ActiveMQMessageProducer {
value=ID:2115-khanaly-1-1856-1191436053617-1:0:1:1 }
Consumer got this:   ActiveMQMessageConsumer {
value=ID:2115-khanaly-1-1856-1191436053617-1:0:1:1, started=false }
Sending request.
ActiveMQTextMessage {commandId = 0, responseRequired = false, messageId =
null, originalDestination = null, originalTransactionId = null, producerId =
null, destination = null, transactionId = null, expiration = 0, timestamp =
0, arrival = 0, correlationId = null, replyTo = null, persistent = false,
type = null, priority = 0, groupID = null, groupSequence = 0,
targetConsumerId = null, compressed = false, userID = null, content = null,
marshalledProperties = null, dataStructure = null, redeliveryCounter = 0,
size = 0, properties = null, readOnlyProperties = false, readOnlyBody =
false, droppable = false, text = Yogi}
Done.


Please comment on the configuration of this file 
mvn jbi:projectDeploy was successful though.

Can I use bean SU and jms-consumer SU for the purpose 
My purpose it to get message from bean.

Regards,
Raj

I am again attaching you my bean xbean.xml files


<beans xmlns:bean="http://servicemix.apache.org/bean/1.0"
       xmlns:y="http://localhost:8192/yrkproject">

  <bean:endpoint service="y:service"
endpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectinput"
bean="#myBean"/>

  <bean id="myBean" class="org.apache.YrkProject.MyBean"/>
</beans>

<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
       xmlns:y="http://localhost:8192/yrkproject"
       xmlns:amq="http://activemq.org/config/1.0">

    
    <jms:endpoint service="y:yrkproject"
                 
endpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
                  targetService="y:service"
                 
targetEndpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
                  role="consumer" 
                  destinationStyle="queue"
                 
jmsProviderDestinationName="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
                  defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
                  defaultOperation="test:Echo"
                  connectionFactory="#connectionFactory" />
     <bean id="#connectionFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
        <property name="connectionFactory">
            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                <property name="brokerURL" value="tcp://localhost:61616"/>
            </bean>
        </property>          
    </bean>    

Thanks once again for your suggestion.I appreciate it.
Regards,
Raj



Raj@nih wrote:
> 
> Hi,
> I made an SA successfully using the servicemix-bean su and  jms-consumer
> su and used mvn command   
> to make SA out of them and build was successful.I wrote a client jms
> program that sends the message.But I couldn't get response back from bean
> I am using simple inout echo bean that you listed on the site.
> I think problem is with my xbean and target point 
> i am sending both here.
> 
> 
> beans xmlns:bean="http://servicemix.apache.org/bean/1.0"
>        xmlns:y="http://localhost:8192/yrkproject">
> 
>   <bean:endpoint service="y:service"
> endpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectinput"
> bean="#myBean"/>
> 
>   <bean id="myBean" class="org.apache.YrkProject.MyBean"/>
> </beans>
> 
> beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
>        xmlns:y="http://localhost:8192/yrkproject"
>        xmlns:amq="http://activemq.org/config/1.0">
> 
>     
>     <jms:endpoint service="y:yrkproject"
>                  
> endpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
>                   targetService="y:yrkproject"
>                  
> targetEndpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
>                   role="consumer" 
>                   destinationStyle="queue"
>                  
> jmsProviderDestinationName="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
>                   defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>                   defaultOperation="test:Echo"
>                   connectionFactory="#connectionFactory" />
>      <bean id="#connectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
>         <property name="connectionFactory">
>             <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>                 <property name="brokerURL" value="tcp://localhost:61616"/>
>             </bean>
>         </property>          
>     </bean>               
>    
> 
>     
> 
> </beans>
> 
> 
> 
> This is my client 
> 
> package nih.nci.gov.caXchange;
> import javax.jbi.messaging.InOut;
> import org.apache.servicemix.client.DefaultServiceMixClient; 
> import org.apache.servicemix.jbi.jaxp.StringSource;
> import javax.xml.namespace.QName; 
> import javax.jms.*;
> 
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.apache.activemq.command.ActiveMQQueue;
> 
> 
> public class TestJmsClient {
> 
> 	/**
> 	 * @param args
> 	 */
> 	public static void main(String[] args) throws JMSException{
> 		 System.out.println("Connecting to JMS server.");
> 		  // ActiveMQ JMS Provider code
>         ActiveMQConnectionFactory factory =                         
>             new ActiveMQConnectionFactory("tcp://localhost:61616"); 
>         Destination inQueue = new
> ActiveMQQueue("nih.nci.gov.caXchange.org.servicemix.yrkprojectsource");
>         Destination outQueue = new
> ActiveMQQueue("nih.nci.gov.caXchange.org.servicemix.yrkprojectoutput");
>         Connection connection = factory.createConnection();         
>         Session session = connection.createSession(false,
> Session.CLIENT_ACKNOWLEDGE);
>      // Create the message 66 and consumer
>         MessageProducer producer = session.createProducer(inQueue);  
>         System.out.println("Producer got this:  "+producer);
>         MessageConsumer consumer = session.createConsumer(outQueue);
>         System.out.println("Consumer got this:   "+consumer);
>         connection.start();  
>         System.out.println("Sending request.");                     
>         //producer.send(session.createTextMessage("<message>Hello,
> world!</message>"));
>         TextMessage tMsg = session.createTextMessage("Yogi");
>         System.out.println(tMsg);
>         tMsg.setJMSReplyTo(inQueue);
>         producer.send(tMsg);
>         connection.close();
>         System.out.println("Done.");
>         
>         
>         
> 		
> 	}
> 	
> 	  /*public void init(ComponentContext context) throws JBIException {
>           this.context = context;
>           context.activateEndpoint(new QName("http://your.namespace",
> "service"), "endpoint");
>   }*/ 
> 	
> 	/*public void testEcho() throws Exception {
> 		DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
> 		InOut me = client.createInOutExchange();
> 		me.setService(new QName("http://bpmscript.org/jbi", "timeout"));
> 		me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
> 		ssertTrue(client.sendSync(me, 1000000));
> 		Exception error = me.getError();
> 		assertTrue(error instanceof TimeoutException);
> 				} */
> 
> }
> 
> 
> Can any one suggest me how do I get reply back from servicemix bean.
> Regards,
> Raj
> 

-- 
View this message in context: http://www.nabble.com/Regarding-servicemix-bean-and-jms-consumer-tf4563322s12049.html#a13025177
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Regarding servicemix bean and jms-consumer

Posted by Bruce Snyder <br...@gmail.com>.
On 10/3/07, Raj@nih <yr...@gmail.com> wrote:
>
> Hi,
> I made an SA successfully using the servicemix-bean su and  jms-consumer su
> and used mvn command
> to make SA out of them and build was successful.I wrote a client jms program
> that sends the message.But I couldn't get response back from bean I am using
> simple inout echo bean that you listed on the site.
> I think problem is with my xbean and target point
> i am sending both here.
>
>
> beans xmlns:bean="http://servicemix.apache.org/bean/1.0"
>        xmlns:y="http://localhost:8192/yrkproject">
>
>   <bean:endpoint service="y:service"
> endpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectinput"
> bean="#myBean"/>
>
>   <bean id="myBean" class="org.apache.YrkProject.MyBean"/>
> </beans>
>
> beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
>        xmlns:y="http://localhost:8192/yrkproject"
>        xmlns:amq="http://activemq.org/config/1.0">
>
>
>     <jms:endpoint service="y:yrkproject"
>
> endpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
>                   targetService="y:yrkproject"
>
> targetEndpoint="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
>                   role="consumer"
>                   destinationStyle="queue"
>
> jmsProviderDestinationName="nih.nci.gov.caXchange.org.servicemix.yrkprojectsource"
>                   defaultMep="http://www.w3.org/2004/08/wsdl/in-out"
>                   defaultOperation="test:Echo"
>                   connectionFactory="#connectionFactory" />
>      <bean id="#connectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
>         <property name="connectionFactory">
>             <bean class="org.apache.activemq.ActiveMQConnectionFactory">
>                 <property name="brokerURL" value="tcp://localhost:61616"/>
>             </bean>
>         </property>
>     </bean>
>
>
>
>
> </beans>
>
>
>
> This is my client
>
> package nih.nci.gov.caXchange;
> import javax.jbi.messaging.InOut;
> import org.apache.servicemix.client.DefaultServiceMixClient;
> import org.apache.servicemix.jbi.jaxp.StringSource;
> import javax.xml.namespace.QName;
> import javax.jms.*;
>
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.apache.activemq.command.ActiveMQQueue;
>
>
> public class TestJmsClient {
>
>         /**
>          * @param args
>          */
>         public static void main(String[] args) throws JMSException{
>                  System.out.println("Connecting to JMS server.");
>                   // ActiveMQ JMS Provider code
>         ActiveMQConnectionFactory factory =
>             new ActiveMQConnectionFactory("tcp://localhost:61616");
>         Destination inQueue = new
> ActiveMQQueue("nih.nci.gov.caXchange.org.servicemix.yrkprojectsource");
>         Destination outQueue = new
> ActiveMQQueue("nih.nci.gov.caXchange.org.servicemix.yrkprojectoutput");
>         Connection connection = factory.createConnection();
>         Session session = connection.createSession(false,
> Session.CLIENT_ACKNOWLEDGE);
>      // Create the message 66 and consumer
>         MessageProducer producer = session.createProducer(inQueue);
>         System.out.println("Producer got this:  "+producer);
>         MessageConsumer consumer = session.createConsumer(outQueue);
>         System.out.println("Consumer got this:   "+consumer);
>         connection.start();
>         System.out.println("Sending request.");
>         //producer.send(session.createTextMessage("<message>Hello,
> world!</message>"));
>         TextMessage tMsg = session.createTextMessage("Yogi");
>         System.out.println(tMsg);
>         tMsg.setJMSReplyTo(inQueue);
>         producer.send(tMsg);
>         connection.close();
>         System.out.println("Done.");
>
>
>
>
>         }
>
>           /*public void init(ComponentContext context) throws JBIException {
>           this.context = context;
>           context.activateEndpoint(new QName("http://your.namespace",
> "service"), "endpoint");
>   }*/
>
>         /*public void testEcho() throws Exception {
>                 DefaultServiceMixClient client = new DefaultServiceMixClient(jbi);
>                 InOut me = client.createInOutExchange();
>                 me.setService(new QName("http://bpmscript.org/jbi", "timeout"));
>                 me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
>                 ssertTrue(client.sendSync(me, 1000000));
>                 Exception error = me.getError();
>                 assertTrue(error instanceof TimeoutException);
>                                 } */
>
> }
>
>
> Can any one suggest me how do I get reply back from servicemix bean.

So what is the inteneded component flow in the SUs? Right now, the
servicemix-jms SU sets a target service of itself:

targetService="y:yrkproject"

This won't make it to the servicemix-bean component. You'll need to
name the servicemix-bean SU in the targetService attribute.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache ActiveMQ - http://activemq.org/
Apache ServiceMix - http://servicemix.org/
Apache Geronimo - http://geronimo.apache.org/
Castor - http://castor.org/