Example usage for org.springframework.context.support ReloadableResourceBundleMessageSource getMessage

List of usage examples for org.springframework.context.support ReloadableResourceBundleMessageSource getMessage

Introduction

In this page you can find the example usage for org.springframework.context.support ReloadableResourceBundleMessageSource getMessage.

Prototype

@Override
    public final String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage,
            Locale locale) 

Source Link

Usage

From source file:cn.webank.queue.biz.service.impl.RetryMessagePojoService.java

private static Runnable constructRunnable(final String namespace, final String queueName, final BaseDTO baseDTO,
        final RetryMessageDTO retryDto, final WeBankServiceDispatcher serviceDispatcher,
        // final int timeoutSeconds,
        final SolacePojoService solaceService, final ReloadableResourceBundleMessageSource bundleMessageSource,
        final RetryMessagePojoService retryService, final JsonMapper jsonMapper) {

    Runnable r = new Runnable() {
        public void run() {
            // 4.1 dispatch service

            try {
                //retry?
                long currentTime = System.currentTimeMillis();
                retryDto.addRetryTimes();
                retryDto.setLastExecutedTime(currentTime);

                BizErrors errors = new BizErrors();

                // TODO ?2
                serviceDispatcher.dispatch(baseDTO.getServiceId(), retryDto.getJsonMessage(), errors);

                // handle result
                if (errors.hasErrors()) {
                    StringBuilder sb = new StringBuilder();
                    boolean isFirst = true;
                    for (BizError error : errors.getAllErrors()) {

                        if (!isFirst) {
                            sb.append("<br />");
                        }/*w  ww  .  j  av a  2  s .c o  m*/
                        sb.append(bundleMessageSource.getMessage(error.getCode(), error.getArguments(),
                                "", Locale.CHINESE));
                        isFirst = false;

                    }

                    LOG.error("biz error:" + sb.toString() + ",message:" + retryDto.getJsonMessage());

                    handleBizException(retryDto);
                } else {
                    LOG.info("retry message success. key:" + retryDto.getKey() + " ");
                }

            } catch (Exception e) {
                // ?
                LOG.error("distach service error,message:" + retryDto.getJsonMessage(), e);
                handleSysException(namespace, queueName, retryDto, e, retryService, jsonMapper);

            }

        }
    };

    return r;

}