org.apache.qpid.proton.amqp.messaging.Header类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中org.apache.qpid.proton.amqp.messaging.Header类的一些代码示例,展示了Header类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Header类的具体详情如下:
包路径:org.apache.qpid.proton.amqp.messaging.Header
类名称:Header

Header介绍

暂无

代码示例

代码示例来源:origin: org.apache.qpid/proton-j-impl

public int size()
{
  return _impl.getDeliveryCount() != null
       ? 5
       : _impl.getFirstAcquirer() != null
       ? 4
       : _impl.getTtl() != null
       ? 3
       : _impl.getPriority() != null
       ? 2
       : _impl.getDurable() != null
       ? 1
       : 0;
}

代码示例来源:origin: apache/qpid-jms

public Header getHeader() {
  Header result = null;
  if (!isDefault()) {
    result = new Header();
    result.setDurable(durable);
    result.setPriority(priority);
    result.setFirstAcquirer(firstAcquirer);
    result.setTtl(timeToLive);
    result.setDeliveryCount(deliveryCount);
  }
  return result;
}

代码示例来源:origin: apache/activemq-artemis

@Override
public org.apache.activemq.artemis.api.core.Message setDurable(boolean durable) {
 if (header == null) {
   header = new Header();
 }
 header.setDurable(durable);  // Message needs to be re-encoded following this action.
 return this;
}

代码示例来源:origin: org.apache.qpid/proton-j

@Override
public void setFirstAcquirer(boolean firstAcquirer)
{
  if (_header == null)
  {
    if (!firstAcquirer)
    {
      return;
    }
    _header = new Header();
  }
  _header.setFirstAcquirer(firstAcquirer);
}

代码示例来源:origin: org.apache.qpid/proton-jms

protected void populateMessage(Message jms, org.apache.qpid.proton.message.Message amqp) throws Exception {
  Header header = amqp.getHeader();
  if( header==null ) {
    header = new Header();
  if( header.getDurable()!=null ) {
    jms.setJMSDeliveryMode(header.getDurable().booleanValue() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
  } else {
    jms.setJMSDeliveryMode(defaultDeliveryMode);
  if( header.getPriority()!=null ) {
    jms.setJMSPriority(header.getPriority().intValue());
  } else {
    jms.setJMSPriority(defaultPriority);
  if( header.getFirstAcquirer() !=null ) {
    jms.setBooleanProperty(prefixVendor + "FirstAcquirer", header.getFirstAcquirer());
  if( header.getDeliveryCount()!=null ) {
    vendor.setJMSXDeliveryCount(jms, header.getDeliveryCount().longValue());
      vendor.setJMSXUserID(jms, new String(userId.getArray(), userId.getArrayOffset(), userId.getLength(), "UTF-8"));
      vendor.setJMSXGroupSequence(jms, properties.getGroupSequence().intValue());
    if( header.getTtl()!=null ) {
      ttl = header.getTtl().longValue();

代码示例来源:origin: org.apache.activemq/activemq-osgi

header = new Header();
  header.setDurable(true);
    header = new Header();
  header.setPriority(UnsignedByte.valueOf(priority));
    header = new Header();
  header.setTtl(new UnsignedInteger((int) ttl));
if (deliveryCount > 0) {
  if (header == null) {
    header = new Header();
  header.setDeliveryCount(UnsignedInteger.valueOf(deliveryCount));
    } else if (key.startsWith(HEADER, JMS_AMQP_PREFIX_LENGTH)) {
      if (header == null) {
        header = new Header();
    } else if (key.startsWith(FIRST_ACQUIRER, JMS_AMQP_PREFIX_LENGTH)) {
      if (header == null) {
        header = new Header();
      header.setFirstAcquirer((boolean) TypeConversionSupport.convert(value, Boolean.class));
      continue;
    } else if (key.startsWith(CONTENT_TYPE, JMS_AMQP_PREFIX_LENGTH)) {

代码示例来源:origin: org.apache.qpid/proton-jms

Header header = new Header();
Properties props=new Properties();
HashMap<Symbol, Object> daMap = null;
  m.readBytes(data);
  body = new Data(new Binary(data));
} if( msg instanceof TextMessage ) {
  body = new AmqpValue(((TextMessage) msg).getText());
header.setDurable(msg.getJMSDeliveryMode() == DeliveryMode.PERSISTENT ? true : false);
header.setPriority(new UnsignedByte((byte) msg.getJMSPriority()));
if( msg.getJMSType()!=null ) {
  if( maMap==null ) maMap = new HashMap<Symbol, Object>();
    ttl = 1;
  header.setTtl(new UnsignedInteger((int)ttl));
    header.setFirstAcquirer(msg.getBooleanProperty(key));
  } else if( key.startsWith("JMSXDeliveryCount") ) {
      header.setDeliveryCount(new UnsignedInteger(amqpDeliveryCount));
    props.setUserId(new Binary(value.getBytes("UTF-8")));
  } else if( key.startsWith("JMSXGroupID") ) {
    String value = msg.getStringProperty(key);

代码示例来源:origin: EnMasseProject/enmasse

/**
 * Return a raw AMQP message
 *
 * @return
 */
public Message toAmqp() {
  Message message = ProtonHelper.message();
  message.setSubject(AMQP_SUBJECT);
  Map<Symbol, Object> map = new HashMap<>();
  map.put(Symbol.valueOf(AMQP_RETAIN_ANNOTATION), this.isRetain);
  map.put(Symbol.valueOf(AMQP_QOS_ANNOTATION), this.qos.value());
  MessageAnnotations messageAnnotations = new MessageAnnotations(map);
  message.setMessageAnnotations(messageAnnotations);
  message.setAddress(this.topic);
  Header header = new Header();
  header.setDurable(this.qos != MqttQoS.AT_MOST_ONCE);
  message.setHeader(header);
  // the payload could be null (or empty)
  if (this.payload != null)
    message.setBody(new Data(new Binary(this.payload.getBytes())));
  return message;
}

代码示例来源:origin: org.apache.activemq/activemq-all

byte encodedData[] = encodedMessage.getArray();
int encodedSize = encodedMessage.getLength();
    amqp.setHeader(new Header());
  amqp.getHeader().setDeliveryCount(new UnsignedInteger(count));

代码示例来源:origin: io.vertx/vertx-amqp-bridge

@Test
public void testJSON_to_AMQP_VerifyMessageHeader() {
 boolean testDurable = true;
 byte testPriority = 8;
 long testTtl = 2345;
 boolean testFirstAcquirer = true;
 long testDeliveryCount = 3;
 JsonObject jsonHeader = new JsonObject();
 jsonHeader.put(AmqpConstants.HEADER_DURABLE, testDurable);
 jsonHeader.put(AmqpConstants.HEADER_PRIORITY, testPriority);
 jsonHeader.put(AmqpConstants.HEADER_TTL, testTtl);
 jsonHeader.put(AmqpConstants.HEADER_FIRST_ACQUIRER, testFirstAcquirer);
 jsonHeader.put(AmqpConstants.HEADER_DELIVERY_COUNT, testDeliveryCount);
 JsonObject jsonObject = new JsonObject();
 jsonObject.put(AmqpConstants.HEADER, jsonHeader);
 Message protonMsg = translator.convertToAmqpMessage(jsonObject);
 assertNotNull("Expected converted msg", protonMsg);
 Header header = protonMsg.getHeader();
 assertNotNull("Header section not present", header);
 assertEquals("expected durable value to be present", testDurable, header.getDurable());
 assertEquals("expected priority value to be present", UnsignedByte.valueOf(testPriority), header.getPriority());
 assertEquals("expected ttl value to be present", UnsignedInteger.valueOf(testTtl), header.getTtl());
 assertEquals("expected first acquirer value to be present", testFirstAcquirer, header.getFirstAcquirer());
 assertEquals("expected delivery count value to be present", UnsignedInteger.valueOf(testDeliveryCount),
   header.getDeliveryCount());
}

代码示例来源:origin: apache/activemq-artemis

protected static ServerJMSMessage processHeader(ServerJMSMessage jms, Header header) throws Exception {
 if (header != null) {
   jms.setBooleanProperty(JMS_AMQP_HEADER, true);
   if (header.getDurable() != null) {
    jms.setBooleanProperty(JMS_AMQP_HEADER_DURABLE, true);
    jms.setJMSDeliveryMode(header.getDurable().booleanValue() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
   } else {
    jms.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
   }
   if (header.getPriority() != null) {
    jms.setBooleanProperty(JMS_AMQP_HEADER_PRIORITY, true);
    jms.setJMSPriority(header.getPriority().intValue());
   } else {
    jms.setJMSPriority(javax.jms.Message.DEFAULT_PRIORITY);
   }
   if (header.getFirstAcquirer() != null) {
    jms.setBooleanProperty(JMS_AMQP_FIRST_ACQUIRER, header.getFirstAcquirer());
   }
   if (header.getDeliveryCount() != null) {
    // AMQP Delivery Count counts only failed delivers where JMS
    // Delivery Count should include the original delivery in the count.
    jms.setLongProperty("JMSXDeliveryCount", header.getDeliveryCount().longValue() + 1);
   }
 } else {
   jms.setJMSPriority((byte) javax.jms.Message.DEFAULT_PRIORITY);
   jms.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
 }
 return jms;
}

代码示例来源:origin: org.apache.qpid/proton

@Override
public void setDeliveryCount(long deliveryCount)
{
  if (_header == null)
  {
    if (deliveryCount == 0l)
    {
      return;
    }
    _header = new Header();
  }
  _header.setDeliveryCount(UnsignedInteger.valueOf(deliveryCount));
}

代码示例来源:origin: apache/activemq-artemis

result = createObjectMessage(messageId, payload.getArray(), payload.getArrayOffset(), payload.getLength(), coreMessageObjectPools);
} else if (isContentType(OCTET_STREAM_CONTENT_TYPE, contentType)) {
 result = createBytesMessage(messageId, payload.getArray(), payload.getArrayOffset(), payload.getLength(), coreMessageObjectPools);
if (header.getTtl() != null) {
 ttl = header.getTtl().longValue();

代码示例来源:origin: apache/activemq-artemis

@Override
public org.apache.activemq.artemis.api.core.Message setPriority(byte priority) {
 if (header == null) {
   header = new Header();
 }
 header.setPriority(UnsignedByte.valueOf(priority));
 return this;
}

代码示例来源:origin: org.apache.qpid/proton-j-impl

@Override
public void setTtl(long ttl)
{
  if (_header == null)
  {
    if (ttl != 0l)
    {
      _header = new Header();
    }
    else
    {
      return;
    }
  }
  _header.setTtl(UnsignedInteger.valueOf(ttl));
}

代码示例来源:origin: org.apache.activemq/artemis-amqp-protocol

@Override
public void sendBuffer(ByteBuf buffer, int deliveryCount) {
 checkBuffer();
 int amqpDeliveryCount = deliveryCount - 1;
 // If the re-delivering the message then the header must be re-encoded
 // otherwise we want to write the original header if present.
 if (amqpDeliveryCount > 0) {
   Header header = getHeader();
   if (header == null) {
    header = new Header();
    header.setDurable(durable);
   }
   synchronized (header) {
    header.setDeliveryCount(UnsignedInteger.valueOf(amqpDeliveryCount));
    TLSEncode.getEncoder().setByteBuffer(new NettyWritable(buffer));
    TLSEncode.getEncoder().writeObject(header);
    TLSEncode.getEncoder().setByteBuffer((WritableBuffer) null);
   }
 } else if (headerEnds > 0) {
   buffer.writeBytes(data.duplicate().limit(headerEnds).byteBuffer());
 }
 data.position(messagePaylodStart);
 buffer.writeBytes(data.byteBuffer());
 data.position(0);
}

代码示例来源:origin: EnMasseProject/enmasse

qos = ((message.getHeader().getDurable() == null) || !message.getHeader().getDurable())
        ? MqttQoS.AT_MOST_ONCE : MqttQoS.AT_LEAST_ONCE;
  } else {
if ((section != null) && (section instanceof Data)) {
  Buffer payload = Buffer.buffer(((Data) section).getValue().getArray());
  return new AmqpWillMessage(isRetain, topic, qos, payload);

代码示例来源:origin: org.apache.qpid/proton-jms

amqp.setHeader(new Header());
amqp.getHeader().setDeliveryCount(new UnsignedInteger(count - 1));

代码示例来源:origin: org.apache.qpid/proton-j-impl

@Override
public long getTtl()
{
  return (_header == null || _header.getTtl() == null) ? 0l : _header.getTtl().longValue();
}

代码示例来源:origin: apache/activemq-artemis

private boolean checkMessageProperties(AMQPMessage message, Map<String, Object> expectedProperties) {
 assertNotNull(message);
 assertNotNull(server.getNodeID());
 assertNotNull(message.getConnectionID());
 assertEquals(message.getAddress(), expectedProperties.get(ADDRESS));
 assertEquals(message.isDurable(), expectedProperties.get(DURABLE));
 Properties props = message.getProperties();
 assertEquals(props.getCorrelationId(), expectedProperties.get(CORRELATION_ID));
 assertEquals(props.getReplyTo(), expectedProperties.get(REPLY_TO));
 assertEquals(props.getMessageId(), expectedProperties.get(MESSAGE_ID));
 Header header = message.getHeader();
 assertEquals(header.getDurable(), expectedProperties.get(DURABLE));
 assertEquals(header.getTtl().toString(), expectedProperties.get(TIME_TO_LIVE).toString());
 assertEquals(header.getPriority().toString(), expectedProperties.get(PRIORITY).toString());
 return true;
}

相关文章