You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Benson Margulies <bi...@gmail.com> on 2012/01/11 17:10:54 UTC

Confused about theads.

I'm trying to sort out the various sources of multi-threadedness when
have a JMS endpoint launched from java. I'm having some trouble
interpreting the email from Freeman quoted, and then I pasted my
launch code.

One way to interpret Freeman's email is that the transport will be
constructing threads, so there's no point to also having an executor
constructing threads.

My goal is to have two threads serving requests over JMS.


Hi,

No, I don't think you also need configure cxf executor, if you
configure executor for the jaxws endpoint,  actually all the
processing is still on the main thread, until
before the invoke call, a runnable will be put on the give executor
which will make the invoke on a background thread, but the main thread
will wait for a response.
The jms configuration I suggest here enable multiple threads from
transport level to get message from queue concurrently and then
dispatch to upstream cxf.

JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
        svrFactory.setServiceClass(TaskEndpoint.class);
        svrFactory.setDataBinding(new AegisDatabinding());
        svrFactory.setAddress(JmsUtils.cxfJmsUrl(taskId, jmsBrokerUrl));
        svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
        svrFactory.setServiceBean(new TaskEndpointErrorProxy(endpoint));
        server = svrFactory.create();
        executorService = Executors.newFixedThreadPool(maxServiceThreads);
        server.getEndpoint().setExecutor(executorService);

Re: Confused about theads.

Posted by Daniel Kulp <dk...@apache.org>.
As Willem said, it's mostly best to allow the transport to handle the 
threading if possible.   With JMS it's really important as things like the 
transaction are associated with the thread.  If you jump threads, you could 
lose the transaction which is likely not the best scenario.

Dan


On Thursday, January 12, 2012 4:54:31 AM Willem Jiang wrote:
> On Thu Jan 12 00:10:54 2012, Benson Margulies wrote:
> > I'm trying to sort out the various sources of multi-threadedness when
> > have a JMS endpoint launched from java. I'm having some trouble
> > interpreting the email from Freeman quoted, and then I pasted my
> > launch code.
> > 
> > One way to interpret Freeman's email is that the transport will be
> > constructing threads, so there's no point to also having an executor
> > constructing threads.
> > 
> > My goal is to have two threads serving requests over JMS.
> > 
> > 
> > Hi,
> > 
> > No, I don't think you also need configure cxf executor, if you
> > configure executor for the jaxws endpoint,  actually all the
> > processing is still on the main thread, until
> > before the invoke call, a runnable will be put on the give executor
> > which will make the invoke on a background thread, but the main thread
> > will wait for a response.
> > The jms configuration I suggest here enable multiple threads from
> > transport level to get message from queue concurrently and then
> > dispatch to upstream cxf.
> 
> I think you can trust the jms transport take care of the thread thing
> of consuming message like http transport does.
> The executor of svrFactory is  just for the service implementation
> invoker.
> 
> > JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
> > 
> >          svrFactory.setServiceClass(TaskEndpoint.class);
> >          svrFactory.setDataBinding(new AegisDatabinding());
> >          svrFactory.setAddress(JmsUtils.cxfJmsUrl(taskId,
> >          jmsBrokerUrl));
> >          svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SP
> >          ECIFICATION_TRANSPORTID);
> >          svrFactory.setServiceBean(new
> >          TaskEndpointErrorProxy(endpoint)); server =
> >          svrFactory.create();
> >          executorService =
> >          Executors.newFixedThreadPool(maxServiceThreads);
> >          server.getEndpoint().setExecutor(executorService);
-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Re: Confused about theads.

Posted by Willem Jiang <wi...@gmail.com>.
On Thu Jan 12 00:10:54 2012, Benson Margulies wrote:
> I'm trying to sort out the various sources of multi-threadedness when
> have a JMS endpoint launched from java. I'm having some trouble
> interpreting the email from Freeman quoted, and then I pasted my
> launch code.
>
> One way to interpret Freeman's email is that the transport will be
> constructing threads, so there's no point to also having an executor
> constructing threads.
>
> My goal is to have two threads serving requests over JMS.
>
>
> Hi,
>
> No, I don't think you also need configure cxf executor, if you
> configure executor for the jaxws endpoint,  actually all the
> processing is still on the main thread, until
> before the invoke call, a runnable will be put on the give executor
> which will make the invoke on a background thread, but the main thread
> will wait for a response.
> The jms configuration I suggest here enable multiple threads from
> transport level to get message from queue concurrently and then
> dispatch to upstream cxf.
>

I think you can trust the jms transport take care of the thread thing 
of consuming message like http transport does.
The executor of svrFactory is  just for the service implementation 
invoker.

> JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
>          svrFactory.setServiceClass(TaskEndpoint.class);
>          svrFactory.setDataBinding(new AegisDatabinding());
>          svrFactory.setAddress(JmsUtils.cxfJmsUrl(taskId, jmsBrokerUrl));
>          svrFactory.setTransportId(JMSSpecConstants.SOAP_JMS_SPECIFICATION_TRANSPORTID);
>          svrFactory.setServiceBean(new TaskEndpointErrorProxy(endpoint));
>          server = svrFactory.create();
>          executorService = Executors.newFixedThreadPool(maxServiceThreads);
>          server.getEndpoint().setExecutor(executorService);
>



-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang