List of usage examples for javax.jms Session AUTO_ACKNOWLEDGE
int AUTO_ACKNOWLEDGE
To view the source code for javax.jms Session AUTO_ACKNOWLEDGE.
Click Source Link
From source file:com.fusesource.forge.jmstest.benchmark.command.transport.JMSCommandTransport.java
public void start() { synchronized (lock) { if (started || released) { return; }//from w ww . j a v a 2s. com ReleaseManager.getInstance().register(this); log().info("JMSCommandTransport (re)starting."); while (!started && !released) { if (getConnection() != null) { try { getConnection().setExceptionListener(this); session = getConnection().createSession(false, Session.AUTO_ACKNOWLEDGE); MessageConsumer consumer = session.createConsumer( getJmsDestinationProvider().getDestination(session, getDestinationName())); consumer.setMessageListener(this); getConnection().start(); started = true; } catch (Exception e) { log().error("Error creating JMSCommandTransport.", e); resetConnection(); } } if (!started) { try { log.warn("Trying to reinitialize JMSTransport Connection in 5 seconds."); Thread.sleep(5000); } catch (InterruptedException e) { } } } if (started) { log().info("JMSCommandTransport started."); } } }
From source file:net.blogracy.services.DownloadService.java
public DownloadService(Connection connection, PluginInterface plugin) { this.plugin = plugin; try {//w w w .ja v a 2 s .co m session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); producer = session.createProducer(null); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); queue = session.createQueue("download"); consumer = session.createConsumer(queue); consumer.setMessageListener(this); } catch (JMSException e) { Logger.error("JMS error: creating download service"); } }
From source file:org.apache.synapse.transport.jms.JMSUtils.java
/** * Create a JMS Queue using the given connection with the JNDI destination name, and return the * JMS Destination name of the created queue * * @param con the JMS Connection to be used * @param destinationJNDIName the JNDI name of the Queue to be created * @return the JMS Destination name of the created Queue * @throws JMSException on error//w ww. j a v a 2s.c o m */ public static String createJMSQueue(Connection con, String destinationJNDIName) throws JMSException { try { QueueSession session = ((QueueConnection) con).createQueueSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = session.createQueue(destinationJNDIName); log.info("JMS Queue with JNDI name : " + destinationJNDIName + " created"); return queue.getQueueName(); } finally { try { con.close(); } catch (JMSException ignore) { } } }
From source file:eu.learnpad.simulator.mon.manager.ResponseDispatcher.java
public static void sendResponse(ComplexEventResponse response, String enablerName, String answerTopic) { try {/*from ww w . j a v a2 s .c om*/ publicSession = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); connectionTopic = publishSession.createTopic(answerTopic); tPub = publishSession.createPublisher(connectionTopic); ObjectMessage sendMessage = publishSession.createObjectMessage(); sendMessage.setObject((Serializable) response); sendMessage.setStringProperty("DESTINATION", enablerName); tPub.publish(sendMessage); } catch (JMSException e) { e.printStackTrace(); } }
From source file:de.taimos.dvalin.interconnect.core.spring.DaemonEvents.java
/** */ public void start() { this.container = new DefaultMessageListenerContainer(); this.container.setPubSubDomain(true); this.container.setConnectionFactory(this.jmsFactory); this.container.setDestinationName("events.global"); this.container.setMessageListener(this); this.container.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE); this.container.setConcurrentConsumers(1); this.container.initialize(); this.container.start(); }
From source file:org.apache.flink.streaming.connectors.jms.JmsQueueSink.java
@Override public void open(final Configuration parameters) throws Exception { super.open(parameters); final String username = parameters.getString("jms_username", null); final String password = parameters.getString("jms_password", null); connection = connectionFactory.createQueueConnection(username, password); final String clientId = parameters.getString("jms_client_id", null); if (clientId != null) connection.setClientID(clientId); session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); producer = session.createSender(destination); connection.start();//from w ww . j a va 2s .c o m }
From source file:org.apache.flink.streaming.connectors.jms.JmsTopicSink.java
@Override public void open(final Configuration parameters) throws Exception { super.open(parameters); final String username = parameters.getString("jms_username", null); final String password = parameters.getString("jms_password", null); connection = connectionFactory.createTopicConnection(username, password); final String clientId = parameters.getString("jms_client_id", null); if (clientId != null) connection.setClientID(clientId); session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); producer = session.createPublisher(destination); connection.start();/*from w ww . j a v a2s.co m*/ }
From source file:org.okj.commons.broker.SimpleMessagePublisher.java
/** * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() *//* ww w.j a v a 2 s . c o m*/ @Override public void afterPropertiesSet() throws Exception { //bean?????? try { if (connectionFactory != null) { //1. ? this.connection = ((TopicConnectionFactory) connectionFactory).createTopicConnection(); //2. ?? this.session = this.connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); //3. this.topic = session.createTopic(topicName); //2. ?? this.connection.start(); LogUtils.info(LOGGER, "???topicName={0}", topicName); } } catch (JMSException ex) { LogUtils.error(LOGGER, "??", ex); } }
From source file:org.apache.activemq.store.kahadb.MultiKahaDBTopicDeletionTest.java
@Override protected void createConsumer(ActiveMQDestination dest) throws JMSException { ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerConnectURI); Connection connection = factory.createConnection(); connection.setClientID("client1"); connection.start();/*from w w w. j a va 2 s . co m*/ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); session.createDurableSubscriber((Topic) dest, "sub1"); }
From source file:com.jaliansystems.activeMQLite.impl.RepositoryService.java
/** * Instantiates a new repository service. * * The queueNamePrefix is used to create a JMS queue with the name appending "-request" to it. * //from ww w . ja va 2s . c o m * @param connection the connection * @param brokerURL the broker url * @param queueNamePrefix the queue name prefix * @param objectRepository the object repository * @param client the client * @throws Exception the exception */ public RepositoryService(Connection connection, String brokerURL, String queueNamePrefix, ObjectRepository objectRepository, RepositoryClient client) throws Exception { this.objectRepository = objectRepository; this.client = client; sessionService = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination requestQueue = sessionService.createQueue(queueNamePrefix + "-request"); MessageConsumer requestConsumer = sessionService.createConsumer(requestQueue); requestConsumer.setMessageListener(this); responseProducer = sessionService.createProducer(null); responseProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); }