use of org.apache.camel.component.sjms2.Sjms2Component in project camel by apache.
the class Jms2TestSupport method createCamelContext.
/*
* @see org.apache.camel.test.junit4.CamelTestSupport#createCamelContext()
* @return
* @throws Exception
*/
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext camelContext = super.createCamelContext();
ConnectionFactory connectionFactory = getConnectionFactory();
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Sjms2Component component = new Sjms2Component();
component.setConnectionCount(1);
component.setConnectionFactory(connectionFactory);
camelContext.addComponent("sjms2", component);
return camelContext;
}
use of org.apache.camel.component.sjms2.Sjms2Component in project camel by apache.
the class Sjms2ComponentAutoConfiguration method configureSjms2Component.
@Lazy
@Bean(name = "sjms2-component")
@ConditionalOnClass(CamelContext.class)
@ConditionalOnMissingBean(Sjms2Component.class)
public Sjms2Component configureSjms2Component(CamelContext camelContext, Sjms2ComponentConfiguration configuration) throws Exception {
Sjms2Component component = new Sjms2Component();
component.setCamelContext(camelContext);
Map<String, Object> parameters = new HashMap<>();
IntrospectionSupport.getProperties(configuration, parameters, null, false);
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
Object value = entry.getValue();
Class<?> paramClass = value.getClass();
if (paramClass.getName().endsWith("NestedConfiguration")) {
Class nestedClass = null;
try {
nestedClass = (Class) paramClass.getDeclaredField("CAMEL_NESTED_CLASS").get(null);
HashMap<String, Object> nestedParameters = new HashMap<>();
IntrospectionSupport.getProperties(value, nestedParameters, null, false);
Object nestedProperty = nestedClass.newInstance();
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), nestedProperty, nestedParameters);
entry.setValue(nestedProperty);
} catch (NoSuchFieldException e) {
}
}
}
IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters);
return component;
}
use of org.apache.camel.component.sjms2.Sjms2Component in project camel by apache.
the class InOnlyTopicDurableConsumerTest method createCamelContext.
/*
* @see org.apache.camel.test.junit4.CamelTestSupport#createCamelContext()
*
* @return
* @throws Exception
*/
@Override
protected CamelContext createCamelContext() throws Exception {
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(BROKER_URI);
ConnectionFactoryResource connectionResource = new ConnectionFactoryResource();
connectionResource.setConnectionFactory(connectionFactory);
connectionResource.setClientId(CONNECTION_ID);
CamelContext camelContext = super.createCamelContext();
Sjms2Component component = new Sjms2Component();
component.setConnectionResource(connectionResource);
component.setConnectionCount(1);
camelContext.addComponent("sjms2", component);
return camelContext;
}
Aggregations