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

x33g5p2x  于2022-01-30 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(166)

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

Symbol介绍

暂无

代码示例

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

@Override
public void setContentType(String contentType)
{
  if(_properties == null)
  {
    if(contentType == null)
    {
      return;
    }
    _properties = new Properties();
  }
  _properties.setContentType(Symbol.valueOf(contentType));
}

代码示例来源:origin: strimzi/strimzi-kafka-bridge

/**
 * Create a new AMQP error condition
 *
 * @param error            AMQP error
 * @param description    description for the AMQP error condition
 * @return                AMQP error condition
 */
static ErrorCondition newError(String error, String description) {
  return new ErrorCondition(Symbol.getSymbol(error), description);
}

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

@Override
public String getContentType()
{
  return (_properties == null || _properties.getContentType() == null) ? null : _properties.getContentType().toString();
}

代码示例来源:origin: stackoverflow.com

@Override
public void serialize(Symbol symbol, JsonGenerator jgen, SerializerProvider serializers) throws IOException, JsonProcessingException {
  jgen.writeStartObject();

  jgen.writeStringField("symbol", symbol.getSymbol());
   //Changed name to full_name as the field name of Json string
  jgen.writeStringField("full_name", symbol.getName());
  jgen.writeEndObject(); 
}

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

private static ServerJMSMessage processProperties(ServerJMSMessage jms, Properties properties) throws Exception {
 if (properties != null) {
   if (properties.getMessageId() != null) {
    jms.setJMSMessageID(AMQPMessageIdHelper.INSTANCE.toMessageIdString(properties.getMessageId()));
   Binary userId = properties.getUserId();
   if (userId != null) {
    jms.setStringProperty("JMSXUserID", new String(userId.getArray(), userId.getArrayOffset(), userId.getLength(), StandardCharsets.UTF_8));
   if (properties.getTo() != null) {
   if (properties.getContentType() != null) {
    jms.setStringProperty(JMS_AMQP_CONTENT_TYPE, properties.getContentType().toString());
   if (properties.getContentEncoding() != null) {
    jms.setStringProperty(JMS_AMQP_CONTENT_ENCODING, properties.getContentEncoding().toString());
   if (properties.getCreationTime() != null) {

代码示例来源:origin: strimzi/strimzi-kafka-bridge

@Override
public Message toMessage(String address, KafkaConsumerRecord<String, byte[]> record) {
  
  Message message = Proton.message();
  message.setAddress(address);
  
  // put message annotations about partition, offset and key (if not null)
  Map<Symbol, Object> map = new HashMap<>();
  map.put(Symbol.valueOf(AmqpBridge.AMQP_PARTITION_ANNOTATION), record.partition());
  map.put(Symbol.valueOf(AmqpBridge.AMQP_OFFSET_ANNOTATION), record.offset());
  map.put(Symbol.valueOf(AmqpBridge.AMQP_KEY_ANNOTATION), record.key());
  map.put(Symbol.valueOf(AmqpBridge.AMQP_TOPIC_ANNOTATION), record.topic());
  
  MessageAnnotations messageAnnotations = new MessageAnnotations(map);
  message.setMessageAnnotations(messageAnnotations);
  
  message.setBody(new Data(new Binary(record.value())));
  
  return message;
}

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

if (messageAnnotations.getValue().containsKey(Symbol.valueOf(AMQP_RETAIN_ANNOTATION))) {
  isRetain = (boolean) messageAnnotations.getValue().get(Symbol.valueOf(AMQP_RETAIN_ANNOTATION));
if (messageAnnotations.getValue().containsKey(Symbol.valueOf(AMQP_QOS_ANNOTATION))) {
  int value = (int) messageAnnotations.getValue().get(Symbol.valueOf(AMQP_QOS_ANNOTATION));
  qos = MqttQoS.valueOf(value);
} 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-j

@Override
  public void run(Selectable selectable) {
    Reactor reactor = selectable.getReactor();
    Transport transport = ((SelectableImpl)selectable).getTransport();
    int capacity = transport.capacity();
    if (capacity > 0) {
      SocketChannel socketChannel = (SocketChannel)selectable.getChannel();
      try {
        int n = socketChannel.read(transport.tail());
        if (n == -1) {
          transport.close_tail();
        } else {
          transport.process();
        }
      } catch (IOException | TransportException e) {
        ErrorCondition condition = new ErrorCondition();
        condition.setCondition(Symbol.getSymbol("proton:io"));
        condition.setDescription(e.getMessage());
        transport.setCondition(condition);
        transport.close_tail();
      }
    }
    // (Comment from C code:) occasionally transport events aren't
    // generated when expected, so the following hack ensures we
    // always update the selector
    update(selectable);
    reactor.update(selectable);
  }
};

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

@Override
public void plain(String username, String password)
{
  client();
  _chosenMechanism = Symbol.valueOf("PLAIN");
  byte[] usernameBytes = username.getBytes(StandardCharsets.UTF_8);
  byte[] passwordBytes = password.getBytes(StandardCharsets.UTF_8);
  byte[] data = new byte[usernameBytes.length+passwordBytes.length+2];
  System.arraycopy(usernameBytes, 0, data, 1, usernameBytes.length);
  System.arraycopy(passwordBytes, 0, data, 2+usernameBytes.length, passwordBytes.length);
  setChallengeResponse(new Binary(data));
}

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

static protected ErrorCondition toError(Throwable value) {
  return new ErrorCondition(Symbol.valueOf("error"), value.toString());
}

代码示例来源:origin: Azure/azure-service-bus-java

amqpMessage.setBody(new Data(new Binary(Utils.getDataFromMessageBody(body))));
amqpMessage.setCorrelationId(brokeredMessage.getCorrelationId());
amqpMessage.setSubject(brokeredMessage.getLabel());
amqpMessage.getProperties().setTo(brokeredMessage.getTo());
amqpMessage.setReplyTo(brokeredMessage.getReplyTo());
amqpMessage.setReplyToGroupId(brokeredMessage.getReplyToSessionId());
if(brokeredMessage.getScheduledEnqueueTimeUtc() != null)
  messageAnnotationsMap.put(Symbol.valueOf(ClientConstants.SCHEDULEDENQUEUETIMENAME), Date.from(brokeredMessage.getScheduledEnqueueTimeUtc()));
  messageAnnotationsMap.put(Symbol.valueOf(ClientConstants.PARTITIONKEYNAME), brokeredMessage.getPartitionKey());
  messageAnnotationsMap.put(Symbol.valueOf(ClientConstants.VIAPARTITIONKEYNAME), brokeredMessage.getViaPartitionKey());
amqpMessage.setMessageAnnotations(new MessageAnnotations(messageAnnotationsMap));

代码示例来源:origin: org.eclipse.hono/hono-core

/**
 * Adds a value for a symbol to an AMQP 1.0 message's <em>annotations</em>.
 *
 * @param msg the message to add the symbol to.
 * @param key the name of the symbol to add a value for.
 * @param value the value to add.
 */
public static void addAnnotation(final Message msg, final String key, final Object value) {
  MessageAnnotations annotations = msg.getMessageAnnotations();
  if (annotations == null) {
    annotations = new MessageAnnotations(new HashMap<>());
    msg.setMessageAnnotations(annotations);
  }
  annotations.getValue().put(Symbol.getSymbol(key), value);
}

代码示例来源:origin: Azure/azure-service-bus-java

messageEntry.put(ClientConstants.REQUEST_RESPONSE_MESSAGE, new Binary(encodedPair.getFirstItem(), 0, encodedPair.getSecondItem()));
messageEntry.put(ClientConstants.REQUEST_RESPONSE_MESSAGE_ID, message.getMessageId());
Object partitionKey = message.getMessageAnnotations().getValue().get(Symbol.valueOf(ClientConstants.PARTITIONKEYNAME));
if(partitionKey != null && !((String)partitionKey).isEmpty())
Object viaPartitionKey = message.getMessageAnnotations().getValue().get(Symbol.valueOf(ClientConstants.VIAPARTITIONKEYNAME));
if(viaPartitionKey != null && !((String)viaPartitionKey).isEmpty())

代码示例来源:origin: eclipse/hono

/**
 * Returns the value to which the specified key is mapped in the message annotations, or {@code null} if the message
 * annotations contain no mapping for the key.
 *
 * @param <T> the expected type of the property to read.
 * @param msg the message that contains the annotations.
 * @param key the name of the symbol to return a value for.
 * @param type the expected type of the value.
 * @return the annotation's value or {@code null} if no such annotation exists or its value is not of the expected
 *         type.
 */
@SuppressWarnings("unchecked")
public static <T> T getAnnotation(final Message msg, final String key, final Class<T> type) {
  final MessageAnnotations annotations = msg.getMessageAnnotations();
  if (annotations == null) {
    return null;
  } else {
    final Object value = annotations.getValue().get(Symbol.getSymbol(key));
    if (type.isInstance(value)) {
      return (T) value;
    } else {
      return null;
    }
  }
}

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

private void actualDelivery(Delivery delivery, Receiver receiver, ReadableBuffer data, Transaction tx) {
 try {
   sessionSPI.serverSend(this, tx, receiver, delivery, address, delivery.getMessageFormat(), data, routingContext);
 } catch (Exception e) {
   log.warn(e.getMessage(), e);
   Rejected rejected = new Rejected();
   ErrorCondition condition = new ErrorCondition();
   if (e instanceof ActiveMQSecurityException) {
    condition.setCondition(AmqpError.UNAUTHORIZED_ACCESS);
   } else {
    condition.setCondition(Symbol.valueOf("failed"));
   }
   connection.runLater(() -> {
    condition.setDescription(e.getMessage());
    rejected.setError(condition);
    delivery.disposition(rejected);
    delivery.settle();
    flow();
    connection.flush();
   });
 }
}

代码示例来源:origin: strimzi/strimzi-kafka-bridge

value = binary.getArray();
partition = messageAnnotations.getValue().get(Symbol.getSymbol(AmqpBridge.AMQP_PARTITION_ANNOTATION));
key = messageAnnotations.getValue().get(Symbol.getSymbol(AmqpBridge.AMQP_KEY_ANNOTATION));

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

@Override
public void setContentEncoding(String contentEncoding)
{
  if(_properties == null)
  {
    if(contentEncoding == null)
    {
      return;
    }
    _properties = new Properties();
  }
  _properties.setContentEncoding(Symbol.valueOf(contentEncoding));
}

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

public static Symbol valueOf(String symbolVal)
{
  return getSymbol(symbolVal);
}

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

/**
 * Lookup and return the correct Proton Symbol instance based on the given key.
 *
 * @param key
 *        the String value name of the Symbol to locate.
 *
 * @return the Symbol value that matches the given key.
 */
public static Symbol getSymbol(String key) {
  return Symbol.valueOf(key);
}

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

@Override
public String getContentEncoding()
{
  return (_properties == null || _properties.getContentEncoding() == null) ? null : _properties.getContentEncoding().toString();
}

相关文章