You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by "Ali, Haneef" <ha...@hp.com> on 2009/05/04 21:40:53 UTC

How to create a multiple instance of a service?

Hi,

I have 2 services. Both the services are created with composite scope.

  a) Webservice which puts the incoming request in a queue
  b) A JMS service which takes the message from the queue and process it.


Even though there are more message in the queue, the JMS service is processing it sequentially. Is it because of "Composite scope"  Is there a way to increase the number of instances of the JMS service?

In pure J2EE we can increase the MDB count. How to do this in Tuscany since it uses MDB underneath?


Thanks,
Haneef

 

Order of start and stop

Posted by "Ali, Haneef" <ha...@hp.com>.
Hi,

What is the order for invoking a method which is annotated by @Init, and @Destroy?


e.g
   a) Assume a service S1 has reference to another service S2.   Which one is stopped first S1 or S2?  Is there any order?
   b) In my case S1 is a webservice and S2 is JMS consumer.  JMS listener is destroyed before S1 can send a stop event


Thanks,
Haneef

Re: How to create a multiple instance of a service?

Posted by ant elder <an...@gmail.com>.
On Tue, May 5, 2009 at 5:19 PM, Raymond Feng <en...@gmail.com> wrote:

>
> 1) The JMS message listener registered by the Tuscany/SCA JMS binding
> provider

> 1 is controlled by the behavior of JMS message listener. By the JMS spec,
> the session used to create the message consumer serializes the execution of
> all message listeners registered with the session. At any time, only one of
> the session's message listeners is running. Each session must insure that it
> passes messages serially to the listener. This means that a listener
> assigned to one or more consumers of the same session can assume that the
> onMessage method is not called with the next message until the session has
> completed the last call.
>

The spec questions aside the current Tuscany implementation uses the
Tuscany work manager thread pool to read messages off the JMS queue on
one thread and dispatch the messages into Tuscany to invoke the
service implementation on other threads, so i would have expected the
messages get processed concurrently. Is there any chance you could
create a small testcase or sample the demonstrates the problem to help
debug whats going on?

   ...ant

Re: How to create a multiple instance of a service?

Posted by Raymond Feng <en...@gmail.com>.
Hi,

This is an interesting question. I don't think the SCA specification defines 
the behavior.

Let's taking the example that an SCA java component service is configured 
with JMS binding. There will be two pieces in the picture.

1) The JMS message listener registered by the Tuscany/SCA JMS binding 
provider
2) The instance(s) of the target java component implementation that is used 
to dispatch the incoming JMS requests

1 is controlled by the behavior of JMS message listener. By the JMS spec, 
the session used to create the message consumer serializes the execution of 
all message listeners registered with the session. At any time, only one of 
the session's message listeners is running. Each session must insure that it 
passes messages serially to the listener. This means that a listener 
assigned to one or more consumers of the same session can assume that the 
onMessage method is not called with the next message until the session has 
completed the last call.

2 is controlled by the scope of the java component. If it is composite 
scoped, the same instance will be used. If it is stateless scoped, a brand 
new instance or an instance from the object pool will be picked. BTW, the 
same instance doesn't mean the dispatching has to be sequential and it's 
possible that the same instance is invoked concurrently.

When 1 delegates the requests to 2, it's not clear if we can pass the 
messages concurrently or sequentially. I will have to get some 
clarifications from the spec group. Maybe we need to have an Intent to 
control the desired behavior.

Thanks,
Raymond
--------------------------------------------------
From: "Ali, Haneef" <ha...@hp.com>
Sent: Monday, May 04, 2009 12:40 PM
To: <us...@tuscany.apache.org>
Subject: How to create a multiple instance of a service?

> Hi,
>
> I have 2 services. Both the services are created with composite scope.
>
>  a) Webservice which puts the incoming request in a queue
>  b) A JMS service which takes the message from the queue and process it.
>
>
> Even though there are more message in the queue, the JMS service is 
> processing it sequentially. Is it because of "Composite scope"  Is there a 
> way to increase the number of instances of the JMS service?
>
> In pure J2EE we can increase the MDB count. How to do this in Tuscany 
> since it uses MDB underneath?
>
>
> Thanks,
> Haneef
>
>