modules/tests/test-integration/src/test/java/org/ballerinalang/test/service/jms/sample/JMSServiceSampleTestCase.java
/**
     * To publish the messages to a queue.
     *
     * @throws JMSException         JMS Exception
     * @throws InterruptedException Interrupted exception while waiting in between messages
     */
To publish the messages to a queue.
@throws JMSException         JMS Exception
@throws InterruptedException Interrupted exception while waiting in between messages
To publish the messages to a queue . @throws JMSException JMS Exception @throws InterruptedException Interrupted exception while waiting in between messages
private void publishMessagesToQueue(String queueName) throws JMSException, InterruptedException {
        ConnectionFactory connectionFactory = JMSBroker.getConnectionFactory();
        QueueConnection queueConn = (QueueConnection) connectionFactory.createConnection();
        queueConn.start();
        QueueSession queueSession = queueConn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
        Destination destination = queueSession.createQueue(queueName);
        MessageProducer queueSender = queueSession.createProducer(destination);
        queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
        for (int index = 0; index < 10; index++) {
            MapMessage queueMessage = queueSession.createMapMessage();
            queueMessage.setInt(mapProperty, index);
            queueSender.send(queueMessage);
            logger.info("Map Message  " + (index + 1) + " sent");
            Thread.sleep(1000);
        }
        queueConn.close();
        queueSession.close();
        queueSender.close();
    }
private void publishMessagesToQueue ( String queueName ) throws JMSException , InterruptedException { ConnectionFactory connectionFactory = JMSBroker . getConnectionFactory ( ) ; QueueConnection queueConn = ( QueueConnection ) connectionFactory . createConnection ( ) ; queueConn . start ( ) ; QueueSession queueSession = queueConn . createQueueSession ( false , Session . AUTO_ACKNOWLEDGE ) ; Destination destination = queueSession . createQueue ( queueName ) ; MessageProducer queueSender = queueSession . createProducer ( destination ) ; queueSender . setDeliveryMode ( DeliveryMode . NON_PERSISTENT ) ; for ( int index = 0 ; index < 10 ; index ++ ) { MapMessage queueMessage = queueSession . createMapMessage ( ) ; queueMessage . setInt ( mapProperty , index ) ; queueSender . send ( queueMessage ) ; logger . info ( "Map Message  " + ( index + 1 ) + " sent" ) ; Thread . sleep ( 1000 ) ; } queueConn . close ( ) ; queueSession . close ( ) ; queueSender . close ( ) ; }
To publish the messages to a queue.
To publish the messages to a queue .