Search in sources :

Example 41 with JmsConnection

use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.

the class ActiveMqPtpPollingConsumerTest method createConsumer.

private StandaloneConsumer createConsumer(EmbeddedActiveMq broker, String threadName, String destinationName) throws Exception {
    PtpPollingConsumer consumer = new PtpPollingConsumer().withQueue(destinationName);
    consumer.setPoller(new FixedIntervalPoller(new TimeInterval(500L, TimeUnit.MILLISECONDS)));
    JmsConnection c = broker.getJmsConnection();
    consumer.setClientId(c.configuredClientId());
    consumer.setUserName(c.configuredUserName());
    consumer.setPassword(c.configuredPassword());
    consumer.setReacquireLockBetweenMessages(true);
    consumer.setVendorImplementation(c.getVendorImplementation());
    StandaloneConsumer sc = new StandaloneConsumer(consumer);
    return sc;
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) PtpPollingConsumer(com.adaptris.core.jms.PtpPollingConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection) FixedIntervalPoller(com.adaptris.core.FixedIntervalPoller) StandaloneConsumer(com.adaptris.core.StandaloneConsumer)

Example 42 with JmsConnection

use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.

the class DefaultEventHandlerTest method retrieveObjectForSampleConfig.

/**
 * @see com.adaptris.core.ExampleConfigCase#retrieveObjectForSampleConfig()
 */
@Override
protected Object retrieveObjectForSampleConfig() {
    Adapter result = null;
    try {
        AdaptrisMessageProducer p = new PtpProducer().withQueue("publishEventsTo");
        DefaultEventHandler eh = new DefaultEventHandler();
        eh.setConnection(new JmsConnection(new StandardJndiImplementation("MyConnectionFactoryName")));
        eh.setProducer(p);
        eh.setMarshaller(DefaultMarshaller.getDefaultMarshaller());
        result = new Adapter();
        result.setChannelList(new ChannelList());
        result.setEventHandler(eh);
        result.setUniqueId(UUID.randomUUID().toString());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return result;
}
Also used : StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PtpProducer(com.adaptris.core.jms.PtpProducer) JmsConnection(com.adaptris.core.jms.JmsConnection)

Example 43 with JmsConnection

use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.

the class SharedComponentListTest method createPtpConnection.

private JmsConnection createPtpConnection(String uniqueId) throws PasswordException {
    JmsConnection c = new JmsConnection();
    StandardJndiImplementation jndi = new StandardJndiImplementation();
    jndi.setJndiName("Connection_Factory_To_Lookup");
    KeyValuePairSet kvps = jndi.getJndiParams();
    kvps.addKeyValuePair(new KeyValuePair(Context.SECURITY_PRINCIPAL, "Administrator"));
    kvps.addKeyValuePair(new KeyValuePair(Context.SECURITY_CREDENTIALS, "Administrator"));
    kvps.addKeyValuePair(new KeyValuePair("com.sonicsw.jndi.mfcontext.domain", "Domain1"));
    kvps.addKeyValuePair(new KeyValuePair(Context.INITIAL_CONTEXT_FACTORY, "com.sonicsw.jndi.mfcontext.MFContextFactory"));
    jndi.getJndiParams().addKeyValuePair(new KeyValuePair(Context.PROVIDER_URL, "tcp://localhost:2506"));
    c.setVendorImplementation(jndi);
    if (!isEmpty(uniqueId)) {
        c.setUniqueId(uniqueId);
    }
    return c;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) JmsConnection(com.adaptris.core.jms.JmsConnection) KeyValuePairSet(com.adaptris.util.KeyValuePairSet)

Example 44 with JmsConnection

use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.

the class RetryingServiceWrapperTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    JmsConnection connection = new JmsConnection();
    connection.setVendorImplementation(new StandardJndiImplementation("MyConnectionFactory"));
    StandaloneProducer wrappedService = new StandaloneProducer();
    wrappedService.setConnection(connection);
    wrappedService.setProducer(new PtpProducer().withQueue(("MyQueueName")));
    RetryingServiceWrapper service = new RetryingServiceWrapper();
    service.setUniqueId("Retrying Service Wrapper");
    service.setNumRetries(10);
    service.setRestartOnFailure(true);
    service.setDelayBetweenRetries(new TimeInterval(10L, TimeUnit.SECONDS));
    service.setService(wrappedService);
    return service;
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) JmsConnection(com.adaptris.core.jms.JmsConnection) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Example 45 with JmsConnection

use of com.adaptris.core.jms.JmsConnection in project interlok by adaptris.

the class JndiImplementationCase method testInitialiseWithTopicConnectionFactoryNotFound.

@Test
public void testInitialiseWithTopicConnectionFactoryNotFound() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    PasProducer producer = new PasProducer().withTopic(queueName);
    StandardJndiImplementation jv = createVendorImplementation();
    JmsConnection c = activeMqBroker.getJndiPasConnection(jv, false, queueName, topicName);
    c.setConnectionAttempts(1);
    c.setConnectionRetryInterval(new TimeInterval(100L, TimeUnit.MILLISECONDS.name()));
    jv.setJndiName("testInitialiseWithTopicConnectionFactoryNotFound");
    StandaloneProducer standaloneProducer = new StandaloneProducer(c, producer);
    try {
        LifecycleHelper.init(standaloneProducer);
        fail("Should Fail to lookup 'testInitialiseWithTopicConnectionFactoryNotFound'");
    } catch (Exception e) {
    // expected
    }
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) PasProducer(com.adaptris.core.jms.PasProducer) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

JmsConnection (com.adaptris.core.jms.JmsConnection)47 Test (org.junit.Test)25 StandaloneProducer (com.adaptris.core.StandaloneProducer)17 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)14 TimeInterval (com.adaptris.util.TimeInterval)14 PasProducer (com.adaptris.core.jms.PasProducer)12 MockChannel (com.adaptris.core.stubs.MockChannel)10 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)8 PtpProducer (com.adaptris.core.jms.PtpProducer)8 KeyValuePair (com.adaptris.util.KeyValuePair)6 Adapter (com.adaptris.core.Adapter)5 PtpConsumer (com.adaptris.core.jms.PtpConsumer)5 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)5 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)4 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)4 SharedConnection (com.adaptris.core.SharedConnection)4 MessageTypeTranslatorImp (com.adaptris.core.jms.MessageTypeTranslatorImp)4 UrlVendorImplementation (com.adaptris.core.jms.UrlVendorImplementation)4 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)4 Message (javax.jms.Message)4