List of usage examples for javax.jms DeliveryMode NON_PERSISTENT
int NON_PERSISTENT
To view the source code for javax.jms DeliveryMode NON_PERSISTENT.
Click Source Link
From source file:net.blogracy.services.DownloadService.java
public DownloadService(Connection connection, PluginInterface plugin) { this.plugin = plugin; try {/*from w w w . j a v a 2s.c o 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:com.jaliansystems.activeMQLite.impl.RepositoryClient.java
/** * Instantiates a new repository client. * /*from w w w. j av a2 s. co m*/ * @param connection * the connection * @param brokerURL * the broker url * @param objectRepository * the object repository * @throws Exception * the exception */ public RepositoryClient(Connection connection, String brokerURL, ObjectRepository objectRepository) throws Exception { this.objectRepository = objectRepository; session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); requestProducer = session.createProducer(null); requestProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); responseQueue = session.createTemporaryQueue(); responseConsumer = session.createConsumer(responseQueue); responseConsumer.setMessageListener(this); }
From source file:com.datatorrent.lib.io.jms.JMSTestBase.java
public void produceMsg(String text) throws Exception { // Create a ConnectionFactory ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); // Create a Connection Connection connection = connectionFactory.createConnection(); connection.start();/*from w ww . j a va 2 s . co m*/ // Create a Session Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); // Create the destination (Topic or Queue) Destination destination = session.createQueue("TEST.FOO"); // Create a MessageProducer from the Session to the Topic or Queue MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); // Create a messages TextMessage message = session.createTextMessage(text); producer.send(message); // Clean up session.close(); connection.close(); }
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. * /*w w w . j a v a 2 s . com*/ * @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); }
From source file:org.eclipse.smila.connectivity.queue.worker.internal.task.impl.Send.java
/** * {@inheritDoc}// www . j a v a2 s. c om * */ @Override public String[] executeInternal(final TaskExecutionEnv env, final SendType config, final Map<String, Properties> idPropertyMap) throws TaskExecutionException, BlackboardAccessException, RecordFilterNotFoundException { Connection connection = null; Session session = null; try { // get cached connection, if do not cache connections -> socket error when many records pushed connection = env.getServices().getBrokerConnections().getConnection(config, true); connection.start(); session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE); final Destination destination = session.createQueue(config.getQueue()); final MessageProducer producer = session.createProducer(destination); if (config.isPersistentDelivery()) { producer.setDeliveryMode(DeliveryMode.PERSISTENT); } else { producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); } final Iterator<Entry<String, Properties>> entries = idPropertyMap.entrySet().iterator(); while (entries.hasNext()) { final Entry<String, Properties> entry = entries.next(); // get message record, optionally a filtered copy. final Record record = createMessageRecord(entry.getKey(), config, env); // prepare queue message. messages are actually sent on session.commit() below. producer.send(createMessage(config, record, entry.getValue(), session)); } // we must commit here so that the message consumer find the correct record version in storages. env.getBlackboard().commit(); env.setCommitRequired(false); // finally send the messages. session.commit(); return idPropertyMap.keySet().toArray(new String[idPropertyMap.size()]); } catch (final Throwable e) { _log.error(msg("Error"), e); rollbackQuietly(session); throw new TaskExecutionException(e); } finally { closeQuietly(session); closeQuietly(connection); } }
From source file:net.blogracy.controller.DistributedHashTable.java
public DistributedHashTable() { try {// w ww . j a v a2 s . c om File recordsFile = new File(CACHE_FOLDER + File.separator + "records.json"); if (recordsFile.exists()) { JSONArray recordList = new JSONArray(new JSONTokener(new FileReader(recordsFile))); for (int i = 0; i < recordList.length(); ++i) { JSONObject record = recordList.getJSONObject(i); records.put(record.getString("id"), record); } } connectionFactory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL); connection = connectionFactory.createConnection(); connection.start(); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); producer = session.createProducer(null); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); lookupQueue = session.createQueue("lookup"); storeQueue = session.createQueue("store"); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.dawnsci.commandserver.core.producer.AliveConsumer.java
protected void startNotifications() throws Exception { if (uri == null) throw new NullPointerException("Please set the URI before starting notifications!"); this.cbean = new ConsumerBean(); cbean.setStatus(ConsumerStatus.STARTING); cbean.setName(getName());/*from ww w. ja va 2 s. c om*/ cbean.setConsumerId(consumerId); cbean.setVersion(consumerVersion); cbean.setStartTime(System.currentTimeMillis()); try { cbean.setHostName(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { // Not fatal but would be nice... e.printStackTrace(); } System.out.println("Running events on topic " + Constants.ALIVE_TOPIC + " to notify of '" + getName() + "' service being available."); final Thread aliveThread = new Thread(new Runnable() { public void run() { try { ConnectionFactory connectionFactory = ConnectionFactoryFacade.createConnectionFactory(uri); aliveConnection = connectionFactory.createConnection(); aliveConnection.start(); final Session session = aliveConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); final Topic topic = session.createTopic(Constants.ALIVE_TOPIC); final MessageProducer producer = session.createProducer(topic); final ObjectMapper mapper = new ObjectMapper(); // Here we are sending the message out to the topic while (isActive()) { try { Thread.sleep(Constants.NOTIFICATION_FREQUENCY); TextMessage temp = session.createTextMessage(mapper.writeValueAsString(cbean)); producer.send(temp, DeliveryMode.NON_PERSISTENT, 1, 5000); if (ConsumerStatus.STARTING.equals(cbean.getStatus())) { cbean.setStatus(ConsumerStatus.RUNNING); } } catch (InterruptedException ne) { break; } catch (Exception neOther) { neOther.printStackTrace(); } } } catch (Exception ne) { ne.printStackTrace(); setActive(false); } } }); aliveThread.setName("Alive Notification Topic"); aliveThread.setDaemon(true); aliveThread.setPriority(Thread.MIN_PRIORITY); aliveThread.start(); }
From source file:net.blogracy.services.LookupService.java
public LookupService(Connection connection, PluginInterface plugin) { this.plugin = plugin; try {/* ww w. j a 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("lookup"); consumer = session.createConsumer(queue); consumer.setMessageListener(this); } catch (JMSException e) { Logger.error("JMS error: creating lookup service"); } }
From source file:org.audit4j.core.AsyncAuditEngine.java
/** * Send./*from w w w. j a v a 2 s . co m*/ * * @param t * the t */ public void send(final Serializable t) { try { final MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); final ObjectMessage objectMessage = session.createObjectMessage(); objectMessage.setObject(t); // Tell the producer to send the message System.out.println("Sent message: " + t.hashCode()); producer.send(objectMessage); } catch (final Exception e) { System.out.println("Caught: " + e); e.printStackTrace(); } }
From source file:com.icesoft.net.messaging.jms.JMSPublisherConnection.java
public void publish(final Message message) throws InvalidDestinationException, JMSException, MessageFormatException, UnsupportedOperationException { if (message != null) { if (connected) { synchronized (connectionLock) { if (connected) { if (topicPublisher == null) { // throws InvalidDestinationException, JMSException. topicPublisher = topicSession.createPublisher(topic); // throws JMSException. topicPublisher.setDeliveryMode(DeliveryMode.NON_PERSISTENT); }/*from w w w .java 2s .c om*/ javax.jms.Message _message = createMessage(message); // throws // InvalidDestinationException, JMSException, // MessageFormatException, // UnsupportedOperationException topicPublisher.publish(_message); if (LOG.isDebugEnabled()) { LOG.debug("[" + jmsAdapter.getMessageServiceClient().getName() + "] Outgoing message:\r\n\r\n" + toString(_message)); } } } } } }