public void handle(RecordInfo recordInfo) { String json = null; switch (recordInfo.getUserRecordType()) { case JournalRecordIds.ADD_MESSAGE: json = parseBytes(recordInfo.id, recordInfo.data); break; case JournalRecordIds.ADD_LARGE_MESSAGE: try { json = largeMessageReader.readJsonInsideFile(recordInfo.id); } catch (IllegalArgumentException ex) { statsBuilder.reportMessageError(recordInfo.id); return; } break; default: statsBuilder.reportMessageError(recordInfo.id); return; } Map map; try { map = objectMapper.readValue(json, Map.class); } catch (Exception e) { throw new RuntimeException(e); } statsBuilder.addEvent(map); }
/** * This will simulate what would happen with topic creationg where a single record is supposed to * be created on the journal * * @throws Exception */ @Test public void testDuplicateDestinationsOnTopic() throws Exception { for (int i = 0; i < 5; i++) { if (server.locateQueue(SimpleString.toSimpleString("jms.topic.tt")) == null) { server.createQueue( SimpleString.toSimpleString("jms.topic.tt"), SimpleString.toSimpleString("jms.topic.tt"), SimpleString.toSimpleString(HornetQServerImpl.GENERIC_IGNORED_FILTER), true, false); } server.stop(); SequentialFileFactory messagesFF = new NIOSequentialFileFactory(getBindingsDir(), null); JournalImpl messagesJournal = new JournalImpl(1024 * 1024, 2, 0, 0, messagesFF, "hornetq-bindings", "bindings", 1); messagesJournal.start(); LinkedList<RecordInfo> infos = new LinkedList<RecordInfo>(); messagesJournal.load(infos, null, null); int bindings = 0; for (RecordInfo info : infos) { if (info.getUserRecordType() == JournalRecordIds.QUEUE_BINDING_RECORD) { bindings++; } } assertEquals(1, bindings); System.out.println("Bindings: " + bindings); messagesJournal.stop(); if (i < 4) server.start(); } }