mirror of https://github.com/apache/activemq.git
Merge pull request #1169 from jbonofre/AMQ-9419
AMQ-9419: Implement createContext(int sessionMode) method
This commit is contained in:
commit
544687465b
|
@ -328,7 +328,11 @@ public class ActiveMQConnectionFactory extends JNDIBaseStorable implements Conne
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public JMSContext createContext(int sessionMode) {
|
public JMSContext createContext(int sessionMode) {
|
||||||
throw new UnsupportedOperationException("createContext() is not supported");
|
try {
|
||||||
|
return new ActiveMQContext(createActiveMQConnection(getUserName(), getPassword()), sessionMode);
|
||||||
|
} catch (JMSException e) {
|
||||||
|
throw JMSExceptionSupport.convertToJMSRuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,9 +57,18 @@ public class ActiveMQJMS2ContextTest extends ActiveMQJMS2TestBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = UnsupportedOperationException.class)
|
@Test
|
||||||
public void testConnectionFactoryCreateContextSession() {
|
public void testConnectionFactoryCreateContextSession() {
|
||||||
activemqConnectionFactory.createContext(Session.AUTO_ACKNOWLEDGE);
|
try(JMSContext jmsContext = activemqConnectionFactory.createContext(Session.AUTO_ACKNOWLEDGE)) {
|
||||||
|
assertNotNull(jmsContext);
|
||||||
|
jmsContext.start();
|
||||||
|
assertTrue(ActiveMQContext.class.isAssignableFrom(jmsContext.getClass()));
|
||||||
|
Destination destination = jmsContext.createQueue(methodNameDestinationName);
|
||||||
|
sendMessage(jmsContext, destination, "Test-" + methodNameDestinationName);
|
||||||
|
recvMessage(jmsContext, destination, "Test-" + methodNameDestinationName);
|
||||||
|
} catch (JMSException e) {
|
||||||
|
fail(e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue