Examples of SubmitMultiResult


Examples of org.jsmpp.bean.SubmitMultiResult

    public void execute(Exchange exchange) throws SmppException {
        SubmitMulti[] submitMulties = createSubmitMulti(exchange);
        List<SubmitMultiResult> results = new ArrayList<SubmitMultiResult>(submitMulties.length);
       
        for (SubmitMulti submitMulti : submitMulties) {
            SubmitMultiResult result;
            log.debug("Sending multiple short messages for exchange id '{}'...", exchange.getExchangeId());
           
            try {
                result = session.submitMultiple(
                        submitMulti.getServiceType(),
                        TypeOfNumber.valueOf(submitMulti.getSourceAddrTon()),
                        NumberingPlanIndicator.valueOf(submitMulti.getSourceAddrNpi()),
                        submitMulti.getSourceAddr(),
                        (Address[]) submitMulti.getDestAddresses(),
                        new ESMClass(submitMulti.getEsmClass()),
                        submitMulti.getProtocolId(),
                        submitMulti.getPriorityFlag(),
                        submitMulti.getScheduleDeliveryTime(),
                        submitMulti.getValidityPeriod(),
                        new RegisteredDelivery(submitMulti.getRegisteredDelivery()),
                        new ReplaceIfPresentFlag(submitMulti.getReplaceIfPresentFlag()),
                        DataCoding.newInstance(submitMulti.getDataCoding()),
                        submitMulti.getSmDefaultMsgId(),
                        submitMulti.getShortMessage(),
                        new OptionalParameter[0]);
                results.add(result);
            } catch (Exception e) {
                throw new SmppException(e);
            }
        }

        log.debug("Sent multiple short messages for exchange id '{}' and received results '{}'", exchange.getExchangeId(), results);

        List<String> messageIDs = new ArrayList<String>(results.size());
        // {messageID : [{destAddr : address, error : errorCode}]}
        Map<String, List<Map<String, Object>>> errors = new HashMap<String, List<Map<String, Object>>>();
       
        for (SubmitMultiResult result : results) {
            UnsuccessDelivery[] deliveries = result.getUnsuccessDeliveries();
           
            if (deliveries != null) {
                List<Map<String, Object>> undelivered = new ArrayList<Map<String, Object>>();
               
                for (UnsuccessDelivery delivery : deliveries) {
                    Map<String, Object> error = new HashMap<String, Object>();
                    error.put(SmppConstants.DEST_ADDR, delivery.getDestinationAddress().getAddress());
                    error.put(SmppConstants.ERROR, delivery.getErrorStatusCode());
                    undelivered.add(error);
                }
               
                if (!undelivered.isEmpty()) {
                    errors.put(result.getMessageId(), undelivered);
                }
            }

            messageIDs.add(result.getMessageId());
        }

        Message message = getResponseMessage(exchange);
        message.setHeader(SmppConstants.ID, messageIDs);
        message.setHeader(SmppConstants.SENT_MESSAGE_COUNT, messageIDs.size());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.