jms消息组成

一个Message对象有三个部分:消息头,消息属性,消息体,消息头提供了和消息有关的元数据,消息属性可以携带由jms客户端设置的属性,jms消费者可以根据消息头和消息属性选择来选择接受消息

消息头:包括自动分配的消息头及开发者分配的消息头

public interface Message
{

    public abstract String getJMSMessageID()
        throws JMSException;

    public abstract void setJMSMessageID(String s)
        throws JMSException;

    public abstract long getJMSTimestamp()
        throws JMSException;

    public abstract void setJMSTimestamp(long l)//jms提供者接受消息的时间
        throws JMSException;

    public abstract byte[] getJMSCorrelationIDAsBytes()
        throws JMSException;

    public abstract void setJMSCorrelationIDAsBytes(byte abyte0[])
        throws JMSException;

    public abstract void setJMSCorrelationID(String s)//开发者分配,将当前的id与之前的特定id进行关联
        throws JMSException;

    public abstract String getJMSCorrelationID()
        throws JMSException;

    public abstract Destination getJMSReplyTo()
        throws JMSException;

    public abstract void setJMSReplyTo(Destination destination)//开发者分配的消息头,表明jms消费者应该应答的地址
        throws JMSException;

    public abstract Destination getJMSDestination()
        throws JMSException;

    public abstract void setJMSDestination(Destination destination)//目的地
        throws JMSException;

    public abstract int getJMSDeliveryMode()
        throws JMSException;

    public abstract void setJMSDeliveryMode(int i)//持久性模式(消息不会丢失,默认)和非持久性模式
        throws JMSException;

    public abstract boolean getJMSRedelivered()
        throws JMSException;

    public abstract void setJMSRedelivered(boolean flag)//是否被重新传送
        throws JMSException;

    public abstract String getJMSType()
        throws JMSException;

    public abstract void setJMSType(String s)//开发者分配,消息类型
        throws JMSException;

    public abstract long getJMSExpiration()
        throws JMSException;

    public abstract void setJMSExpiration(long l)//一个message对象的有效期,在发送者上,可通过setTimeToLive(long l)设置该发送者发送的所有消息的时效,为0表示永不过期
        throws JMSException;

    public abstract int getJMSPriority()
        throws JMSException;

    public abstract void setJMSPriority(int i)//0-4普通优先级,5-9加急优先级,生产者可使用setPriority()方法声明
        throws JMSException;
}

 消息属性:开发者可以自定义能满足他们需要的所有属性

public abstract void clearProperties()
        throws JMSException;

    public abstract boolean propertyExists(String s)
        throws JMSException;

    public abstract boolean getBooleanProperty(String s)
        throws JMSException;

    public abstract byte getByteProperty(String s)
        throws JMSException;

    public abstract short getShortProperty(String s)
        throws JMSException;

    public abstract int getIntProperty(String s)
        throws JMSException;

    public abstract long getLongProperty(String s)
        throws JMSException;

    public abstract float getFloatProperty(String s)
        throws JMSException;

    public abstract double getDoubleProperty(String s)
        throws JMSException;

    public abstract String getStringProperty(String s)
        throws JMSException;

    public abstract Object getObjectProperty(String s)
        throws JMSException;

    public abstract Enumeration getPropertyNames()
        throws JMSException;

    public abstract void setBooleanProperty(String s, boolean flag)
        throws JMSException;

    public abstract void setByteProperty(String s, byte byte0)
        throws JMSException;

    public abstract void setShortProperty(String s, short word0)
        throws JMSException;

    public abstract void setIntProperty(String s, int i)
        throws JMSException;

    public abstract void setLongProperty(String s, long l)
        throws JMSException;

    public abstract void setFloatProperty(String s, float f)
        throws JMSException;

    public abstract void setDoubleProperty(String s, double d)
        throws JMSException;

    public abstract void setStringProperty(String s, String s1)
        throws JMSException;

    public abstract void setObjectProperty(String s, Object obj)
        throws JMSException;

    public abstract void acknowledge()
        throws JMSException;

    public abstract void clearBody()
        throws JMSException;

消息类型

TextMessage,ObjectMessage,BytesMsssage,StreamMessage,MapMessage

posted on 2017-03-20 14:53  伪善者ql  阅读(146)  评论(0编辑  收藏  举报

导航