use of org.hisp.dhis.message.MessageSender in project dhis2-core by dhis2.
the class ServiceConfig method defaultOutboundMessageBatchService.
@Bean("org.hisp.dhis.outboundmessage.OutboundMessageService")
public DefaultOutboundMessageBatchService defaultOutboundMessageBatchService(SmsMessageSender smsMessageSender, EmailMessageSender emailMessageSender) {
Map<DeliveryChannel, MessageSender> channels = new HashMap<>();
channels.put(DeliveryChannel.SMS, smsMessageSender);
channels.put(DeliveryChannel.EMAIL, emailMessageSender);
DefaultOutboundMessageBatchService service = new DefaultOutboundMessageBatchService();
service.setMessageSenders(channels);
return service;
}
use of org.hisp.dhis.message.MessageSender in project dhis2-core by dhis2.
the class DefaultOutboundMessageBatchService method send.
// ---------------------------------------------------------------------
// Supportive Methods
// ---------------------------------------------------------------------
private OutboundMessageResponseSummary send(OutboundMessageBatch batch) {
DeliveryChannel channel = batch.getDeliveryChannel();
MessageSender sender = messageSenders.get(channel);
if (sender == null) {
String errorMessage = String.format("No server/gateway found for delivery channel %s", channel);
log.error(errorMessage);
return new OutboundMessageResponseSummary(errorMessage, channel, OutboundMessageBatchStatus.FAILED);
} else if (!sender.isConfigured()) {
String errorMessage = String.format("Server/gateway for delivery channel %s is not configured", channel);
log.error(errorMessage);
return new OutboundMessageResponseSummary(errorMessage, channel, OutboundMessageBatchStatus.FAILED);
}
log.info("Invoking message sender: " + sender.getClass().getSimpleName());
return sender.sendMessageBatch(batch);
}
Aggregations