[ 
https://issues.apache.org/jira/browse/CAMEL-9916?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15261869#comment-15261869
 ] 

Catalina-Alina Dobrica commented on CAMEL-9916:
-----------------------------------------------

I don't set up the connection pool - it is currently handled in SJMS, in the 
component's doStart and doStop methods. What I propose is doing it in the 
endpoint's doStart and doStop, as I suggest the ConnectionFactory should belong 
to the endpoint instead of the component. Keeping, of course, the backward 
compatibility.
Here's a simple use-case of the restart issue (which is not restricted to XML 
usage):
{code}
/**
Using a basic use-case of SJMS component + ActiveMQConnectionFactory, context 
cannot be restarted
**/
@Test
public void useCase() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
ActiveMQConnectionFactory connectionFactory = new 
ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useJmx=false");
registry.put("activemq", connectionFactory);
DefaultCamelContext context = new DefaultCamelContext(registry);
//adding a connection factory to a SJMS component instance, as per the current 
usage of this component
SjmsComponent sjmsComponent = new SjmsComponent();
sjmsComponent.setConnectionFactory(connectionFactory);
context.addComponent("sjms", sjmsComponent);
//with no added complexity in the route
RouteBuilder routeBuilder = new RouteBuilder(context) {
@Override
public void configure() throws Exception {
from("sjms:queue:test").log("$
{body}
");
}
};
context.addRoutes(routeBuilder);
//when the context starts, SjmsComponent.doStart creates a 
ConnectionFactoryResource with an underlying GenericObjectPool<Connection>, 
even if the pool size is 1 (default = this use-case) and fills the pool
context.start();
//when the context starts, SjmsComponent.doStop drains the pool
context.stop();
//FAIL - the context cannot start again because of an NPE in SjmsConsumer when 
trying to borrowConnection from the ConnectionFactoryResource
context.start();
context.stop();
}{code}

> SJMS component is not currently nodev/XML route compatible
> ----------------------------------------------------------
>
>                 Key: CAMEL-9916
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9916
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-sjms
>            Reporter: Catalina-Alina Dobrica
>
> SJMS component is currently not friendly for XML route usage because:
> * You need a component instance which has been "activated" - has had a 
> connection factory set.
> * On route restart, the component cannot be reused because the underlying 
> pool is closed and not recreated



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to