use of org.thingsboard.server.extensions.rabbitmq.action.RabbitMqActionPayload in project thingsboard by thingsboard.
the class RabbitMqMsgHandler method process.
@Override
public void process(PluginContext ctx, TenantId tenantId, RuleId ruleId, RuleToPluginMsg<?> msg) throws RuleException {
if (!(msg instanceof RabbitMqActionMsg)) {
throw new RuleException("Unsupported message type " + msg.getClass().getName() + "!");
}
RabbitMqActionPayload payload = ((RabbitMqActionMsg) msg).getPayload();
AMQP.BasicProperties properties = convert(payload.getMessageProperties());
try {
channel.basicPublish(payload.getExchange() != null ? payload.getExchange() : "", payload.getQueueName(), properties, payload.getPayload().getBytes(UTF8));
if (payload.isSync()) {
ctx.reply(new ResponsePluginToRuleMsg(msg.getUid(), tenantId, ruleId, BasicStatusCodeResponse.onSuccess(payload.getMsgType(), payload.getRequestId())));
}
} catch (IOException e) {
throw new RuleException(e.getMessage(), e);
}
}
Aggregations