Search in sources :

Example 1 with MessagingException

use of com.metabroadcast.common.queue.MessagingException in project atlas-deer by atlasapi.

the class AbstractEquivalentContentStore method updateContent.

@Override
public final void updateContent(Id contentId) throws WriteException {
    metricRegistry.meter(updateContent + METER_CALLED).mark();
    try {
        lock.lock(contentId);
        Content content = resolveId(contentId);
        ImmutableList<Id> ids = ImmutableList.of(contentId);
        ListenableFuture<OptionalMap<Id, EquivalenceGraph>> graphs = graphStore.resolveIds(ids);
        Optional<EquivalenceGraph> possibleGraph = get(graphs).get(content.getId());
        EquivalenceGraph graph;
        if (possibleGraph.isPresent()) {
            graph = possibleGraph.get();
            update(graph, content);
        } else {
            graph = EquivalenceGraph.valueOf(content.toRef());
            update(graph, content);
        }
        sendEquivalentContentChangedMessage(content, graph);
    } catch (MessagingException | InterruptedException e) {
        metricRegistry.meter(updateContent + METER_FAILURE).mark();
        throw new WriteException("Updating " + contentId, e);
    } finally {
        lock.unlock(contentId);
    }
}
Also used : WriteException(org.atlasapi.entity.util.WriteException) MessagingException(com.metabroadcast.common.queue.MessagingException) OptionalMap(com.metabroadcast.common.collect.OptionalMap) Id(org.atlasapi.entity.Id) EquivalenceGraph(org.atlasapi.equivalence.EquivalenceGraph)

Example 2 with MessagingException

use of com.metabroadcast.common.queue.MessagingException in project atlas-deer by atlasapi.

the class AbstractScheduleStore method sendUpdateMessage.

private void sendUpdateMessage(Publisher source, List<ScheduleHierarchy> content, ScheduleBlocksUpdate update, Channel channel, Interval interval) throws WriteException {
    try {
        String messageId = UUID.randomUUID().toString();
        Timestamp messageTimestamp = Timestamp.of(DateTime.now(DateTimeZones.UTC));
        ScheduleRef updateRef = scheduleRef(content, channel, interval);
        ImmutableSet<BroadcastRef> staleRefs = broadcastRefs(update.getStaleEntries());
        ScheduleUpdateMessage message = new ScheduleUpdateMessage(messageId, messageTimestamp, new ScheduleUpdate(source, updateRef, staleRefs));
        Id channelId = message.getScheduleUpdate().getSchedule().getChannel();
        messageSender.sendMessage(message, Longs.toByteArray(channelId.longValue()));
    } catch (MessagingException e) {
        throw new WriteException(e);
    }
}
Also used : WriteException(org.atlasapi.entity.util.WriteException) MessagingException(com.metabroadcast.common.queue.MessagingException) BroadcastRef(org.atlasapi.content.BroadcastRef) Id(org.atlasapi.entity.Id) Timestamp(com.metabroadcast.common.time.Timestamp)

Example 3 with MessagingException

use of com.metabroadcast.common.queue.MessagingException in project atlas-persistence by atlasapi.

the class MongoScheduleStore method sendUpdateMessage.

private void sendUpdateMessage(Publisher publisher, Channel channel, Interval interval) {
    String mid = UUID.randomUUID().toString();
    Timestamp ts = timestamper.timestamp();
    String src = publisher.key();
    String cid = idCodec.encode(BigInteger.valueOf(channel.getId()));
    DateTime start = interval.getStart();
    DateTime end = interval.getEnd();
    ScheduleUpdateMessage msg = new ScheduleUpdateMessage(mid, ts, src, cid, start, end);
    try {
        messageSender.sendMessage(msg, msg.getChannel().getBytes());
    } catch (MessagingException e) {
        String errMsg = String.format("%s %s %s", src, cid, interval);
        log.error(errMsg, e);
    }
}
Also used : MessagingException(com.metabroadcast.common.queue.MessagingException) Timestamp(com.metabroadcast.common.time.Timestamp) DateTime(org.joda.time.DateTime) ScheduleUpdateMessage(org.atlasapi.messaging.v3.ScheduleUpdateMessage)

Example 4 with MessagingException

use of com.metabroadcast.common.queue.MessagingException in project atlas-deer by atlasapi.

the class AbstractSegmentStore method writeMessage.

private void writeMessage(WriteResult<Segment, Segment> result) {
    ResourceUpdatedMessage msg = createEntityUpdatedMessage(result);
    try {
        Id resourceId = msg.getUpdatedResource().getId();
        sender.sendMessage(msg, Longs.toByteArray(resourceId.longValue()));
    } catch (MessagingException e) {
        log.error("Failed to send resource update message [{}] - {}", msg.getUpdatedResource().toString(), e.toString());
    }
}
Also used : MessagingException(com.metabroadcast.common.queue.MessagingException) ResourceUpdatedMessage(org.atlasapi.messaging.ResourceUpdatedMessage) Id(org.atlasapi.entity.Id)

Example 5 with MessagingException

use of com.metabroadcast.common.queue.MessagingException in project atlas-deer by atlasapi.

the class ConsumingMessageSender method suppressed.

private MessagingException suppressed(List<MessagingException> exceptions) {
    MessagingException ex = new MessagingException("An exception occurred processing message");
    exceptions.forEach(ex::addSuppressed);
    return ex;
}
Also used : MessagingException(com.metabroadcast.common.queue.MessagingException)

Aggregations

MessagingException (com.metabroadcast.common.queue.MessagingException)6 Id (org.atlasapi.entity.Id)4 WriteException (org.atlasapi.entity.util.WriteException)3 Timestamp (com.metabroadcast.common.time.Timestamp)2 EquivalenceGraph (org.atlasapi.equivalence.EquivalenceGraph)2 Optional (com.google.common.base.Optional)1 OptionalMap (com.metabroadcast.common.collect.OptionalMap)1 BroadcastRef (org.atlasapi.content.BroadcastRef)1 ResourceUpdatedMessage (org.atlasapi.messaging.ResourceUpdatedMessage)1 ScheduleUpdateMessage (org.atlasapi.messaging.v3.ScheduleUpdateMessage)1 DateTime (org.joda.time.DateTime)1