You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Carmelo Parma <gi...@gmail.com> on 2008/08/27 19:19:56 UTC

Problem with annotated bean

Hi,

I have a problem with an annotated bean like this:

public class MyBean 
{
   private HashMap<String, MessageExchange> map = new HashMap<String,
MessageExchange>();

   @Operation(name = "myOp")
    public void myOp(MessageExchange exchange) {  	
       	if (exchange.getStatus()==ExchangeStatus.DONE)
    		return; 

				......
				String requestID = ""+System.currentTimeMillis();
				map.put(requestID,exchange);
                               
System.out.println("---status"+exchange.getStatus());
    }
   

	public void answer(String requestID) {
		try {
		       MessageExchange me = map.get(requestID);
		       NormalizedMessage out = me.createMessage();
			     .....
	         me.setMessage(out, "out");
	         channel.send(me);
		} catch (MessagingException e) {
			.....
		}
	}
}

I'd like to save (in my HashMap) the MessageExchange I received, because I'd
like to send back it in the method answer(), that is called somewhere else. 

 but Servicemix throw this exception (just after the method myOp returns): 

---statusActive
ERROR - BeanComponent                  - Error processing exchange InOut[
  id: ID:192.168.1.100-11c051f1cea-10:0
  status: Done
  role: provider
  service: {http://www.....}service1
  endpoint: broker
  operation: {http://www.....}myOp
  in: null
]
javax.jbi.messaging.MessagingException: illegal exchange status: done
        at
org.apache.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(Me
ssageExchangeImpl.java:626)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(Delive
ryChannelImpl.java:385)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.send(Delivery
ChannelImpl.java:431)
        at
org.apache.servicemix.common.EndpointDeliveryChannel.send(EndpointDel
iveryChannel.java:79)
        at
org.apache.servicemix.common.endpoints.SimpleEndpoint.send(SimpleEndp
oint.java:67)
        at
org.apache.servicemix.common.endpoints.SimpleEndpoint.done(SimpleEndp
oint.java:78)
        at
org.apache.servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoi
nt.java:265)
        at
org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:211
)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLi
feCycle.java:538)
        at
org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(Async
BaseLifeCycle.java:490)
        at
org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLife
Cycle.java:46)
        at
org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBoun
d(DeliveryChannelImpl.java:610)
        at
org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlo
w.java:170)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.j
ava:167)
        at
org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.jav
a:134)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:885)
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:907)
        at java.lang.Thread.run(Thread.java:619)


***  Uncaught Exception for agent agentBroker  ***
java.lang.IllegalStateException: component is not owner
        at
org.apache.servicemix.jbi.messaging.MessageExchangeImpl.setMessage(Me
ssageExchangeImpl.java:338)
        at agents.MyBean.answer(MyBean.java:200)
        at agents.AgentBroker$MyBehaviour.action(AgentBroker.java:100)
        at jade.core.behaviours.Behaviour.actionWrapper(Behaviour.java:340)
        at jade.core.Agent$ActiveLifeCycle.execute(Agent.java:1530)
        at jade.core.Agent.run(Agent.java:1468)
        at java.lang.Thread.run(Thread.java:619)
ERROR: Agent agentBroker died without being properly terminated !!!
State was 2
-- 
View this message in context: http://www.nabble.com/Problem-with-annotated-bean-tp19185388p19185388.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Problem with annotated bean

Posted by "Lukasz L." <Lu...@sabre.com>.
ok I understand but unfortunately I don't know what can cause the problem,
I recall some JIRA for this kind of error but I don't if it is your case,
you may try to search the net about this error unless you've already done it


Carmelo Parma wrote:
> 
> My bean doesn't implement the interface MessageExchangeListener (that has
> the method onMessageExchange). 
> I use the annotation, like:
> 
>  @Operation(name = "myOp") 
> public void myOp(MessageExchange exchange) {  
>     .... }
> In such way, the method 'myOp' is called, when my bean receives a
> MessageExchange with setted the Operation 'myOp'.
> Then, my bean doesn't send the response ("out" message) immediately. 
> Another class (not a component) will call the method 'answer' (of my
> bean). This method should send the "out" message but Servicemix throws an
> Exception: the MessageExchange status is setted DONE.. why? 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-annotated-bean-tp19185388p19218570.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Problem with annotated bean

Posted by Carmelo Parma <gi...@gmail.com>.
My bean doesn't implement the interface MessageExchangeListener (that has the
method onMessageExchange). 
I use the annotation, like:

 @Operation(name = "myOp") 
public void myOp(MessageExchange exchange) {  
    .... }
In such way, the method 'myOp' is called, when my bean receives a
MessageExchange with setted the Operation 'myOp'.
Then, my bean doesn't send the response ("out" message) immediately. 
Another class (not a component) will call the method 'answer' (of my bean).
This method should send the "out" message but Servicemix throws an
Exception: the MessageExchange status is setted DONE.. why? 







Lukasz L. wrote:
> 
> so which of your methods is called when your service receives message? (I
> normally saw onMessageExchange present in bean and it was called, I'm not
> sure how it works in you example)
> 
> As for DONE status - each Message Exchange Patterns says exactly what are
> communication step between two services. In case of InOut MEP which is
> your case these steps are:
> 
> consumer send IN message (status is Active)
> provider (you) sends OUT message (status is Acitve)
> consumer changes status to Done and send it back to indicate that MEP is
> finished
> 
> you can't sent MessageExchange if its status is done, 
> I'm not sure how your example works, can you provide some more information
> so I can know what is activities sequence? When the other class is
> invoked? Is it in the same component?
> 
> 
> 
> Carmelo Parma wrote:
>> 
>> the 'answer' method is called from another my class. But the problem is
>> that the InOut MessageExchange status is setted DONE by someone I don't
>> know.. who and why?   :)
>> 
>> 
>> Lukasz L. wrote:
>>> 
>>> Where and when exactly the 'answer' method is called? From what you
>>> wrote I understand that is not called at all right?
>>> 
>>> 
>>> Carmelo Parma wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> I have a problem with an annotated bean like this:
>>>> 
>>>> public class MyBean 
>>>> {
>>>>    private HashMap<String, MessageExchange> map = new HashMap<String,
>>>> MessageExchange>();
>>>> 
>>>>    @Operation(name = "myOp")
>>>>     public void myOp(MessageExchange exchange) {  	
>>>>        	if (exchange.getStatus()==ExchangeStatus.DONE)
>>>>     		return; 
>>>> 
>>>> 				......
>>>> 				String requestID = ""+System.currentTimeMillis();
>>>> 				map.put(requestID,exchange);
>>>>                                
>>>> System.out.println("---status"+exchange.getStatus());
>>>>     }
>>>>    
>>>> 
>>>> 	public void answer(String requestID) {
>>>> 		try {
>>>> 		       MessageExchange me = map.get(requestID);
>>>> 		       NormalizedMessage out = me.createMessage();
>>>> 			     .....
>>>> 	         me.setMessage(out, "out");
>>>> 	         channel.send(me);
>>>> 		} catch (MessagingException e) {
>>>> 			.....
>>>> 		}
>>>> 	}
>>>> }
>>>> 
>>>> I'd like to save (in my HashMap) the MessageExchange I received,
>>>> because I'd like to send back it in the method answer(), that is called
>>>> somewhere else. 
>>>> 
>>>>  but Servicemix throw this exception (just after the method myOp
>>>> returns): 
>>>> 
>>>> ---statusActive
>>>> ERROR - BeanComponent                  - Error processing exchange
>>>> InOut[
>>>>   id: ID:192.168.1.100-11c051f1cea-10:0
>>>>   status: Done
>>>>   role: provider
>>>>   service: {http://www.....}service1
>>>>   endpoint: broker
>>>>   operation: {http://www.....}myOp
>>>>   in: null
>>>> ]
>>>> javax.jbi.messaging.MessagingException: illegal exchange status: done
>>>>         at
>>>> org.apache.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(Me
>>>> ssageExchangeImpl.java:626)
>>>>         at
>>>> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(Delive
>>>> ryChannelImpl.java:385)
>>>>         at
>>>> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.send(Delivery
>>>> ChannelImpl.java:431)
>>>>         at
>>>> org.apache.servicemix.common.EndpointDeliveryChannel.send(EndpointDel
>>>> iveryChannel.java:79)
>>>>         at
>>>> org.apache.servicemix.common.endpoints.SimpleEndpoint.send(SimpleEndp
>>>> oint.java:67)
>>>>         at
>>>> org.apache.servicemix.common.endpoints.SimpleEndpoint.done(SimpleEndp
>>>> oint.java:78)
>>>>         at
>>>> org.apache.servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoi
>>>> nt.java:265)
>>>>         at
>>>> org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:211
>>>> )
>>>>         at
>>>> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLi
>>>> feCycle.java:538)
>>>>         at
>>>> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(Async
>>>> BaseLifeCycle.java:490)
>>>>         at
>>>> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLife
>>>> Cycle.java:46)
>>>>         at
>>>> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBoun
>>>> d(DeliveryChannelImpl.java:610)
>>>>         at
>>>> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlo
>>>> w.java:170)
>>>>         at
>>>> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.j
>>>> ava:167)
>>>>         at
>>>> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.jav
>>>> a:134)
>>>>         at
>>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
>>>> utor.java:885)
>>>>         at
>>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
>>>> .java:907)
>>>>         at java.lang.Thread.run(Thread.java:619)
>>>> 
>>>> 
>>>> ***  Uncaught Exception for agent agentBroker  ***
>>>> java.lang.IllegalStateException: component is not owner
>>>>         at
>>>> org.apache.servicemix.jbi.messaging.MessageExchangeImpl.setMessage(Me
>>>> ssageExchangeImpl.java:338)
>>>>         at agents.MyBean.answer(MyBean.java:200)
>>>>         at agents.AgentBroker$MyBehaviour.action(AgentBroker.java:100)
>>>>         at
>>>> jade.core.behaviours.Behaviour.actionWrapper(Behaviour.java:340)
>>>>         at jade.core.Agent$ActiveLifeCycle.execute(Agent.java:1530)
>>>>         at jade.core.Agent.run(Agent.java:1468)
>>>>         at java.lang.Thread.run(Thread.java:619)
>>>> ERROR: Agent agentBroker died without being properly terminated !!!
>>>> State was 2
>>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-annotated-bean-tp19185388p19214723.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Problem with annotated bean

Posted by "Lukasz L." <Lu...@sabre.com>.
so which of your methods is called when your service receives message? (I
normally saw onMessageExchange present in bean and it was called, I'm not
sure how it works in you example)

As for DONE status - each Message Exchange Patterns says exactly what are
communication step between two services. In case of InOut MEP which is your
case these steps are:

consumer send IN message (status is Active)
provider (you) sends OUT message (status is Acitve)
consumer changes status to Done and send it back to indicate that MEP is
finished

you can't sent MessageExchange if its status is done, 
I'm not sure how your example works, can you provide some more information
so I can know what is activities sequence? When the other class is invoked?
Is it in the same component?



Carmelo Parma wrote:
> 
> the 'answer' method is called from another my class. But the problem is
> that the InOut MessageExchange status is setted DONE by someone I don't
> know.. who and why?   :)
> 
> 
> Lukasz L. wrote:
>> 
>> Where and when exactly the 'answer' method is called? From what you wrote
>> I understand that is not called at all right?
>> 
>> 
>> Carmelo Parma wrote:
>>> 
>>> Hi,
>>> 
>>> I have a problem with an annotated bean like this:
>>> 
>>> public class MyBean 
>>> {
>>>    private HashMap<String, MessageExchange> map = new HashMap<String,
>>> MessageExchange>();
>>> 
>>>    @Operation(name = "myOp")
>>>     public void myOp(MessageExchange exchange) {  	
>>>        	if (exchange.getStatus()==ExchangeStatus.DONE)
>>>     		return; 
>>> 
>>> 				......
>>> 				String requestID = ""+System.currentTimeMillis();
>>> 				map.put(requestID,exchange);
>>>                                
>>> System.out.println("---status"+exchange.getStatus());
>>>     }
>>>    
>>> 
>>> 	public void answer(String requestID) {
>>> 		try {
>>> 		       MessageExchange me = map.get(requestID);
>>> 		       NormalizedMessage out = me.createMessage();
>>> 			     .....
>>> 	         me.setMessage(out, "out");
>>> 	         channel.send(me);
>>> 		} catch (MessagingException e) {
>>> 			.....
>>> 		}
>>> 	}
>>> }
>>> 
>>> I'd like to save (in my HashMap) the MessageExchange I received, because
>>> I'd like to send back it in the method answer(), that is called
>>> somewhere else. 
>>> 
>>>  but Servicemix throw this exception (just after the method myOp
>>> returns): 
>>> 
>>> ---statusActive
>>> ERROR - BeanComponent                  - Error processing exchange
>>> InOut[
>>>   id: ID:192.168.1.100-11c051f1cea-10:0
>>>   status: Done
>>>   role: provider
>>>   service: {http://www.....}service1
>>>   endpoint: broker
>>>   operation: {http://www.....}myOp
>>>   in: null
>>> ]
>>> javax.jbi.messaging.MessagingException: illegal exchange status: done
>>>         at
>>> org.apache.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(Me
>>> ssageExchangeImpl.java:626)
>>>         at
>>> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(Delive
>>> ryChannelImpl.java:385)
>>>         at
>>> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.send(Delivery
>>> ChannelImpl.java:431)
>>>         at
>>> org.apache.servicemix.common.EndpointDeliveryChannel.send(EndpointDel
>>> iveryChannel.java:79)
>>>         at
>>> org.apache.servicemix.common.endpoints.SimpleEndpoint.send(SimpleEndp
>>> oint.java:67)
>>>         at
>>> org.apache.servicemix.common.endpoints.SimpleEndpoint.done(SimpleEndp
>>> oint.java:78)
>>>         at
>>> org.apache.servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoi
>>> nt.java:265)
>>>         at
>>> org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:211
>>> )
>>>         at
>>> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLi
>>> feCycle.java:538)
>>>         at
>>> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(Async
>>> BaseLifeCycle.java:490)
>>>         at
>>> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLife
>>> Cycle.java:46)
>>>         at
>>> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBoun
>>> d(DeliveryChannelImpl.java:610)
>>>         at
>>> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlo
>>> w.java:170)
>>>         at
>>> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.j
>>> ava:167)
>>>         at
>>> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.jav
>>> a:134)
>>>         at
>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
>>> utor.java:885)
>>>         at
>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
>>> .java:907)
>>>         at java.lang.Thread.run(Thread.java:619)
>>> 
>>> 
>>> ***  Uncaught Exception for agent agentBroker  ***
>>> java.lang.IllegalStateException: component is not owner
>>>         at
>>> org.apache.servicemix.jbi.messaging.MessageExchangeImpl.setMessage(Me
>>> ssageExchangeImpl.java:338)
>>>         at agents.MyBean.answer(MyBean.java:200)
>>>         at agents.AgentBroker$MyBehaviour.action(AgentBroker.java:100)
>>>         at
>>> jade.core.behaviours.Behaviour.actionWrapper(Behaviour.java:340)
>>>         at jade.core.Agent$ActiveLifeCycle.execute(Agent.java:1530)
>>>         at jade.core.Agent.run(Agent.java:1468)
>>>         at java.lang.Thread.run(Thread.java:619)
>>> ERROR: Agent agentBroker died without being properly terminated !!!
>>> State was 2
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-annotated-bean-tp19185388p19202219.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Problem with annotated bean

Posted by Carmelo Parma <gi...@gmail.com>.
the 'answer' method is called from another my class. But the problem is that
the InOut MessageExchange status is setted DONE by someone I don't know..
who and why?   :)


Lukasz L. wrote:
> 
> Where and when exactly the 'answer' method is called? From what you wrote
> I understand that is not called at all right?
> 
> 
> Carmelo Parma wrote:
>> 
>> Hi,
>> 
>> I have a problem with an annotated bean like this:
>> 
>> public class MyBean 
>> {
>>    private HashMap<String, MessageExchange> map = new HashMap<String,
>> MessageExchange>();
>> 
>>    @Operation(name = "myOp")
>>     public void myOp(MessageExchange exchange) {  	
>>        	if (exchange.getStatus()==ExchangeStatus.DONE)
>>     		return; 
>> 
>> 				......
>> 				String requestID = ""+System.currentTimeMillis();
>> 				map.put(requestID,exchange);
>>                                
>> System.out.println("---status"+exchange.getStatus());
>>     }
>>    
>> 
>> 	public void answer(String requestID) {
>> 		try {
>> 		       MessageExchange me = map.get(requestID);
>> 		       NormalizedMessage out = me.createMessage();
>> 			     .....
>> 	         me.setMessage(out, "out");
>> 	         channel.send(me);
>> 		} catch (MessagingException e) {
>> 			.....
>> 		}
>> 	}
>> }
>> 
>> I'd like to save (in my HashMap) the MessageExchange I received, because
>> I'd like to send back it in the method answer(), that is called somewhere
>> else. 
>> 
>>  but Servicemix throw this exception (just after the method myOp
>> returns): 
>> 
>> ---statusActive
>> ERROR - BeanComponent                  - Error processing exchange InOut[
>>   id: ID:192.168.1.100-11c051f1cea-10:0
>>   status: Done
>>   role: provider
>>   service: {http://www.....}service1
>>   endpoint: broker
>>   operation: {http://www.....}myOp
>>   in: null
>> ]
>> javax.jbi.messaging.MessagingException: illegal exchange status: done
>>         at
>> org.apache.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(Me
>> ssageExchangeImpl.java:626)
>>         at
>> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(Delive
>> ryChannelImpl.java:385)
>>         at
>> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.send(Delivery
>> ChannelImpl.java:431)
>>         at
>> org.apache.servicemix.common.EndpointDeliveryChannel.send(EndpointDel
>> iveryChannel.java:79)
>>         at
>> org.apache.servicemix.common.endpoints.SimpleEndpoint.send(SimpleEndp
>> oint.java:67)
>>         at
>> org.apache.servicemix.common.endpoints.SimpleEndpoint.done(SimpleEndp
>> oint.java:78)
>>         at
>> org.apache.servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoi
>> nt.java:265)
>>         at
>> org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:211
>> )
>>         at
>> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLi
>> feCycle.java:538)
>>         at
>> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(Async
>> BaseLifeCycle.java:490)
>>         at
>> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLife
>> Cycle.java:46)
>>         at
>> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBoun
>> d(DeliveryChannelImpl.java:610)
>>         at
>> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlo
>> w.java:170)
>>         at
>> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.j
>> ava:167)
>>         at
>> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.jav
>> a:134)
>>         at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
>> utor.java:885)
>>         at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
>> .java:907)
>>         at java.lang.Thread.run(Thread.java:619)
>> 
>> 
>> ***  Uncaught Exception for agent agentBroker  ***
>> java.lang.IllegalStateException: component is not owner
>>         at
>> org.apache.servicemix.jbi.messaging.MessageExchangeImpl.setMessage(Me
>> ssageExchangeImpl.java:338)
>>         at agents.MyBean.answer(MyBean.java:200)
>>         at agents.AgentBroker$MyBehaviour.action(AgentBroker.java:100)
>>         at
>> jade.core.behaviours.Behaviour.actionWrapper(Behaviour.java:340)
>>         at jade.core.Agent$ActiveLifeCycle.execute(Agent.java:1530)
>>         at jade.core.Agent.run(Agent.java:1468)
>>         at java.lang.Thread.run(Thread.java:619)
>> ERROR: Agent agentBroker died without being properly terminated !!!
>> State was 2
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-annotated-bean-tp19185388p19201982.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Problem with annotated bean

Posted by "Lukasz L." <Lu...@sabre.com>.
Where and when exactly the 'answer' method is called? From what you wrote I
understand that is not called at all right?


Carmelo Parma wrote:
> 
> Hi,
> 
> I have a problem with an annotated bean like this:
> 
> public class MyBean 
> {
>    private HashMap<String, MessageExchange> map = new HashMap<String,
> MessageExchange>();
> 
>    @Operation(name = "myOp")
>     public void myOp(MessageExchange exchange) {  	
>        	if (exchange.getStatus()==ExchangeStatus.DONE)
>     		return; 
> 
> 				......
> 				String requestID = ""+System.currentTimeMillis();
> 				map.put(requestID,exchange);
>                                
> System.out.println("---status"+exchange.getStatus());
>     }
>    
> 
> 	public void answer(String requestID) {
> 		try {
> 		       MessageExchange me = map.get(requestID);
> 		       NormalizedMessage out = me.createMessage();
> 			     .....
> 	         me.setMessage(out, "out");
> 	         channel.send(me);
> 		} catch (MessagingException e) {
> 			.....
> 		}
> 	}
> }
> 
> I'd like to save (in my HashMap) the MessageExchange I received, because
> I'd like to send back it in the method answer(), that is called somewhere
> else. 
> 
>  but Servicemix throw this exception (just after the method myOp returns): 
> 
> ---statusActive
> ERROR - BeanComponent                  - Error processing exchange InOut[
>   id: ID:192.168.1.100-11c051f1cea-10:0
>   status: Done
>   role: provider
>   service: {http://www.....}service1
>   endpoint: broker
>   operation: {http://www.....}myOp
>   in: null
> ]
> javax.jbi.messaging.MessagingException: illegal exchange status: done
>         at
> org.apache.servicemix.jbi.messaging.MessageExchangeImpl.handleSend(Me
> ssageExchangeImpl.java:626)
>         at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.doSend(Delive
> ryChannelImpl.java:385)
>         at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.send(Delivery
> ChannelImpl.java:431)
>         at
> org.apache.servicemix.common.EndpointDeliveryChannel.send(EndpointDel
> iveryChannel.java:79)
>         at
> org.apache.servicemix.common.endpoints.SimpleEndpoint.send(SimpleEndp
> oint.java:67)
>         at
> org.apache.servicemix.common.endpoints.SimpleEndpoint.done(SimpleEndp
> oint.java:78)
>         at
> org.apache.servicemix.bean.BeanEndpoint.onProviderExchange(BeanEndpoi
> nt.java:265)
>         at
> org.apache.servicemix.bean.BeanEndpoint.process(BeanEndpoint.java:211
> )
>         at
> org.apache.servicemix.common.AsyncBaseLifeCycle.doProcess(AsyncBaseLi
> feCycle.java:538)
>         at
> org.apache.servicemix.common.AsyncBaseLifeCycle.processExchange(Async
> BaseLifeCycle.java:490)
>         at
> org.apache.servicemix.common.BaseLifeCycle.onMessageExchange(BaseLife
> Cycle.java:46)
>         at
> org.apache.servicemix.jbi.messaging.DeliveryChannelImpl.processInBoun
> d(DeliveryChannelImpl.java:610)
>         at
> org.apache.servicemix.jbi.nmr.flow.AbstractFlow.doRouting(AbstractFlo
> w.java:170)
>         at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaFlow.doRouting(SedaFlow.j
> ava:167)
>         at
> org.apache.servicemix.jbi.nmr.flow.seda.SedaQueue$1.run(SedaQueue.jav
> a:134)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
> utor.java:885)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
> .java:907)
>         at java.lang.Thread.run(Thread.java:619)
> 
> 
> ***  Uncaught Exception for agent agentBroker  ***
> java.lang.IllegalStateException: component is not owner
>         at
> org.apache.servicemix.jbi.messaging.MessageExchangeImpl.setMessage(Me
> ssageExchangeImpl.java:338)
>         at agents.MyBean.answer(MyBean.java:200)
>         at agents.AgentBroker$MyBehaviour.action(AgentBroker.java:100)
>         at
> jade.core.behaviours.Behaviour.actionWrapper(Behaviour.java:340)
>         at jade.core.Agent$ActiveLifeCycle.execute(Agent.java:1530)
>         at jade.core.Agent.run(Agent.java:1468)
>         at java.lang.Thread.run(Thread.java:619)
> ERROR: Agent agentBroker died without being properly terminated !!!
> State was 2
> 

-- 
View this message in context: http://www.nabble.com/Problem-with-annotated-bean-tp19185388p19199712.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.