use of org.apache.activemq.ActiveMQConnectionFactory in project activemq-artemis by apache.
the class ConfigUsingDestinationOptionsTest method testInvalidSelectorConfig.
@Test(timeout = 60000)
public void testInvalidSelectorConfig() throws JMSException {
ActiveMQQueue queue = new ActiveMQQueue("TEST.FOO?consumer.selector=test||1");
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("vm://localhost");
Connection conn = factory.createConnection();
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
ActiveMQMessageConsumer cons;
// JMS selector should be priority
try {
cons = (ActiveMQMessageConsumer) sess.createConsumer(queue, "test||1");
fail("Selector should be invalid" + cons);
} catch (InvalidSelectorException e) {
}
// Test setting using JMS destinations
try {
cons = (ActiveMQMessageConsumer) sess.createConsumer(queue);
fail("Selector should be invalid" + cons);
} catch (InvalidSelectorException e) {
}
}
use of org.apache.activemq.ActiveMQConnectionFactory in project activemq-artemis by apache.
the class AMQ3410Test method testNoFactorySet.
public void testNoFactorySet() throws Exception {
AmqBrowseCommand command = new AmqBrowseCommand();
CommandContext context = new CommandContext();
context.setFormatter(new CommandShellOutputFormatter(System.out));
command.setCommandContext(context);
List<String> tokens = new ArrayList<>();
tokens.addAll(DEFAULT_OPTIONS);
tokens.addAll(DEFAULT_TOKENS);
command.execute(tokens);
assertNotNull(command.getConnectionFactory());
assertTrue(command.getConnectionFactory() instanceof ActiveMQConnectionFactory);
}
use of org.apache.activemq.ActiveMQConnectionFactory in project activemq-artemis by apache.
the class DefaultQueueSender method main.
public static void main(String[] args) {
String uri = "tcp://localhost:61616";
String text = "Hello World!";
Connection connection = null;
if (args.length < 1) {
printUsage();
System.exit(1);
}
int idx = 0;
String arg = args[0];
if (arg.equals("-uri")) {
if (args.length == 1) {
printUsage();
System.exit(1);
}
uri = args[1];
idx += 2;
}
String queueName = args[idx];
LOG.info("Connecting to: " + uri);
LOG.info("Queue name is " + queueName);
if (++idx < args.length) {
text = args[idx];
}
try {
ConnectionFactory factory = new ActiveMQConnectionFactory(uri);
connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(queueName);
MessageProducer producer = session.createProducer(destination);
Message message = session.createTextMessage(text);
producer.send(message);
} catch (JMSException e) {
LOG.info("Exception occurred: " + e.toString());
} finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException e) {
}
}
}
}
use of org.apache.activemq.ActiveMQConnectionFactory in project activemq-artemis by apache.
the class CheckDuplicateMessagesOnDuplexTest method openLocalConnection.
private void openLocalConnection() throws JMSException {
localFactory = new ActiveMQConnectionFactory(localBroker.getVmConnectorURI());
// localFactory.setSendAcksAsync(false);
localConnection = localFactory.createConnection();
localConnection.start();
localSession = localConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = localSession.createConsumer(localSession.createQueue("testqueue"));
}
use of org.apache.activemq.ActiveMQConnectionFactory in project activemq-artemis by apache.
the class CheckDuplicateMessagesOnDuplexTest method openRemoteConnection.
private void openRemoteConnection() throws JMSException {
remoteFactory = new ActiveMQConnectionFactory(remoteBroker.getVmConnectorURI());
// remoteFactory.setSendAcksAsync(false);
remoteConnection = remoteFactory.createConnection();
remoteConnection.start();
remoteSession = remoteConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = remoteSession.createProducer(remoteSession.createQueue("testqueue"));
}
Aggregations