Refine search
@Override public void setContentType(String contentType) { if(_properties == null) { if(contentType == null) { return; } _properties = new Properties(); } _properties.setContentType(Symbol.valueOf(contentType)); }
/** * 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); }
@Override public String getContentType() { return (_properties == null || _properties.getContentType() == null) ? null : _properties.getContentType().toString(); }
@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(); }
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) {
@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; }
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);
@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); } };
@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)); }
static protected ErrorCondition toError(Throwable value) { return new ErrorCondition(Symbol.valueOf("error"), value.toString()); }
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));
/** * 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); }
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())
/** * 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; } } }
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(); }); } }
@Override public void setContentEncoding(String contentEncoding) { if(_properties == null) { if(contentEncoding == null) { return; } _properties = new Properties(); } _properties.setContentEncoding(Symbol.valueOf(contentEncoding)); }
public static Symbol valueOf(String symbolVal) { return getSymbol(symbolVal); }
/** * 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); }
@Override public String getContentEncoding() { return (_properties == null || _properties.getContentEncoding() == null) ? null : _properties.getContentEncoding().toString(); }