All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.atomikos.jms.extra.MessageCallback Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
/**
 * Copyright (C) 2000-2023 Atomikos 
 *
 * LICENSE CONDITIONS
 *
 * See http://www.atomikos.com/Main/WhichLicenseApplies for details.
 */

package com.atomikos.jms.extra;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;

abstract class MessageCallback implements JmsSenderTemplateCallback
{

	private final Destination replyToDestination;
	private final Destination destination;
	private final int priority;
	private final long ttl;
	private final int deliveryMode;

	protected MessageCallback ( Destination destination , Destination replyToDestination , int deliveryMode  , int priority , long ttl )
	{
		this.destination = destination;
		this.replyToDestination = replyToDestination;
		this.priority = priority;
		this.ttl = ttl;
		this.deliveryMode = deliveryMode;
	}

	protected void sendMessage ( Message m , Session s ) throws JMSException
	{
	    if ( replyToDestination != null )
            m.setJMSReplyTo ( replyToDestination );
        MessageProducer mp = s.createProducer( destination );
        mp.send ( m , deliveryMode, priority, ttl );
        mp.close();
	}
	 @Override
	public void doInJmsSession(Session session) throws JMSException {
		 sendMessage(createMessage(session), session);
	}
	

	abstract Message createMessage(Session session) throws JMSException;


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy