Search in sources :

Example 1 with MessageWriteException

use of jp.ossc.nimbus.service.writer.MessageWriteException in project nimbus by nimbus-org.

the class WsServiceMetricsHandlerService method consume.

/**
 * 出力先が設定されていれば、。<p>
 *
 * @param dequeued null
 * @param ctrl DaemonControlオブジェクト
 */
public void consume(Object dequeued, DaemonControl ctrl) {
    Date timestamp = new Date();
    if (keyAndCategoryMap != null && keyAndCategoryMap.size() != 0) {
        final Iterator keys = keyAndCategoryMap.keySet().iterator();
        while (keys.hasNext()) {
            final String key = (String) keys.next();
            final Category category = (Category) keyAndCategoryMap.get(key);
            final MetricsInfo info = (MetricsInfo) metricsInfos.get(key);
            if (info != null && category != null) {
                try {
                    category.write(createRecord(timestamp, info));
                } catch (MessageWriteException e) {
                // TODO ログ出力
                }
            }
        }
    }
    if (metricsCategory != null) {
        final MetricsInfo[] infos = (MetricsInfo[]) metricsInfos.values().toArray(new MetricsInfo[metricsInfos.size()]);
        Arrays.sort(infos, COMP);
        for (int i = 0; i < infos.length; i++) {
            try {
                metricsCategory.write(createRecord(timestamp, i + 1, infos[i]));
            } catch (MessageWriteException e) {
            // TODO ログ出力
            }
        }
    }
    if (isResetByOutput) {
        final MetricsInfo[] infos = (MetricsInfo[]) metricsInfos.values().toArray(new MetricsInfo[metricsInfos.size()]);
        for (int i = 0; i < infos.length; i++) {
            infos[i].reset();
        }
    }
}
Also used : MetricsInfo(jp.ossc.nimbus.service.aop.interceptor.MetricsInfo) Category(jp.ossc.nimbus.service.writer.Category) Iterator(java.util.Iterator) MessageWriteException(jp.ossc.nimbus.service.writer.MessageWriteException) Date(java.util.Date)

Example 2 with MessageWriteException

use of jp.ossc.nimbus.service.writer.MessageWriteException in project nimbus by nimbus-org.

the class DestinationWriterService method write.

public void write(WritableRecord rec) throws MessageWriteException {
    Session session = messageProducerFactory.getSession();
    Message message = null;
    try {
        message = messageCreator.createMessage(session, rec);
    } catch (Exception e) {
        getLogger().write(JMSDW00001, e);
        throw new MessageWriteException(e);
    }
    try {
        if (message != null) {
            send(message);
        }
    } catch (JMSException e) {
        getLogger().write(JMSDW00002, e);
        try {
            session.rollback();
        } catch (Exception ex) {
            getLogger().write(JMSDW00003, ex);
        }
        throw new MessageWriteException(e);
    }
    try {
        session.commit();
    } catch (Exception e) {
        getLogger().write(JMSDW00004, e);
        throw new MessageWriteException(e);
    }
}
Also used : MessageWriteException(jp.ossc.nimbus.service.writer.MessageWriteException) MessageWriteException(jp.ossc.nimbus.service.writer.MessageWriteException)

Aggregations

MessageWriteException (jp.ossc.nimbus.service.writer.MessageWriteException)2 Date (java.util.Date)1 Iterator (java.util.Iterator)1 MetricsInfo (jp.ossc.nimbus.service.aop.interceptor.MetricsInfo)1 Category (jp.ossc.nimbus.service.writer.Category)1