Java Code Examples for javax.jms.MapMessage#getInt()

The following examples show how to use javax.jms.MapMessage#getInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageOrderingTest.java    From olat with Apache License 2.0 6 votes vote down vote up
public void onMessage(Message arg0) {
    try {
        if (!(arg0 instanceof MapMessage)) {
            new Exception("Wrong message type: " + arg0).printStackTrace(System.out);
            System.exit(1);
        }
        MapMessage message = (MapMessage) arg0;
        int receivedCounter = message.getInt("Counter");
        System.out.println("Received counter=" + receivedCounter);
        if (receivedCounter != counter_) {
            new Exception("Out of order, expected " + counter_ + ", but got " + receivedCounter).printStackTrace(System.out);
            System.exit(1);
        }
        counter_++;
    } catch (JMSException e) {
        e.printStackTrace(System.out);
        System.exit(1);
    }
}
 
Example 2
Source File: MessageOrderingTest.java    From olat with Apache License 2.0 6 votes vote down vote up
public void onMessage(Message arg0) {
    try {
        if (!(arg0 instanceof MapMessage)) {
            new Exception("Wrong message type: " + arg0).printStackTrace(System.out);
            System.exit(1);
        }
        MapMessage message = (MapMessage) arg0;
        int receivedCounter = message.getInt("Counter");
        System.out.println("Received counter=" + receivedCounter);
        if (receivedCounter != counter_) {
            new Exception("Out of order, expected " + counter_ + ", but got " + receivedCounter).printStackTrace(System.out);
            System.exit(1);
        }
        counter_++;
    } catch (JMSException e) {
        e.printStackTrace(System.out);
        System.exit(1);
    }
}
 
Example 3
Source File: MessageReceiver.java    From voj with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 处理评测机完成单个测试点的消息.
 * @param mapMessage - 消息队列中收到的MapMessage对象
 * @throws JMSException
 */
private void testPointFinishedHandler(MapMessage mapMessage) throws JMSException {
	long submissionId = mapMessage.getLong("submissionId");
	int checkpointId = mapMessage.getInt("checkpointId");
	String runtimeResult = mapMessage.getString("runtimeResult");
	int usedTime = mapMessage.getInt("usedTime");
	int usedMemory = mapMessage.getInt("usedMemory");
	int score = mapMessage.getInt("score");
	
	String message = String.format("- Test Point #%d: %s, Time = %d ms, Memory = %d KB, Score = %d\n", 
						new Object[] { checkpointId, runtimeResult, usedTime, usedMemory, score });
	eventPublisher.publishEvent(new SubmissionEvent(this, submissionId, "Running", message, false));
	
	LOGGER.info(String.format("Submission #%d/ CheckPoint#%d returned [%s] (Time = %dms, Memory = %d KB, Score = %d).",
			new Object[] { submissionId, checkpointId, runtimeResult, usedTime, usedMemory, score }));
}
 
Example 4
Source File: ServerStatusMessage.java    From chipster with MIT License 6 votes vote down vote up
public void unmarshal(MapMessage from) throws JMSException {
	super.unmarshal(from);
	
	this.load = from.getDouble(KEY_CPU_LOAD);
	this.cores = from.getInt(KEY_CPU_CORES);
	this.cpuPercents = from.getInt(KEY_CPU_PERCENTS);
	this.memUsed = from.getLong(KEY_MEM_USED);
	this.memTotal = from.getLong(KEY_MEM_TOTAL);
	this.memPercents = from.getInt(KEY_MEM_PERCENTS);
	this.diskUsed = from.getLong(KEY_DISK_USED);		
	this.diskTotal = from.getLong(KEY_DISK_TOTAL);
	this.diskPercents = from.getInt(KEY_DISK_PERCENTS);
	this.scheduledJobs = from.getInt(KEY_SCHEDULED_JOBS);
	this.runningJobs = from.getInt(KEY_RUNNING_JOBS);
	this.host = from.getString(KEY_HOST);
	this.hostId = from.getString(KEY_HOST_ID);
	this.status = from.getString(KEY_STATUS);
}
 
Example 5
Source File: CompressedInteropTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private void receiveMapMessage(boolean useCore) throws Exception {
   MapMessage mapMessage = (MapMessage) receiveMessage(useCore);

   boolean booleanVal = mapMessage.getBoolean("boolean-type");
   assertTrue(booleanVal);
   byte byteVal = mapMessage.getByte("byte-type");
   assertEquals((byte) 10, byteVal);
   byte[] bytesVal = mapMessage.getBytes("bytes-type");
   byte[] originVal = TEXT.getBytes();
   assertEquals(originVal.length, bytesVal.length);
   for (int i = 0; i < bytesVal.length; i++) {
      assertTrue(bytesVal[i] == originVal[i]);
   }
   char charVal = mapMessage.getChar("char-type");
   assertEquals('A', charVal);
   double doubleVal = mapMessage.getDouble("double-type");
   assertEquals(55.3D, doubleVal, 0.1D);
   float floatVal = mapMessage.getFloat("float-type");
   assertEquals(79.1F, floatVal, 0.1F);
   int intVal = mapMessage.getInt("int-type");
   assertEquals(37, intVal);
   long longVal = mapMessage.getLong("long-type");
   assertEquals(56652L, longVal);
   Object objectVal = mapMessage.getObject("object-type");
   Object origVal = new String("VVVV");
   assertTrue(objectVal.equals(origVal));
   short shortVal = mapMessage.getShort("short-type");
   assertEquals((short) 333, shortVal);
   String strVal = mapMessage.getString("string-type");
   assertEquals(TEXT, strVal);
}
 
Example 6
Source File: MessageReceiver.java    From voj with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 处理评测机完成全部测试点的消息.
 * @param mapMessage - 消息队列中收到的MapMessage对象
 * @throws JMSException
 */
private void allTestPointsFinishedHandler(MapMessage mapMessage) throws JMSException {
	long submissionId = mapMessage.getLong("submissionId");
	String runtimeResult = mapMessage.getString("runtimeResult");
	int usedTime = mapMessage.getInt("totalTime");
	int usedMemory = mapMessage.getInt("maxMemory");
	int score = mapMessage.getInt("totalScore");
	
	String message = String.format("\n%s, Time = %d ms, Memory = %d KB, Score = %d\n", 
						new Object[] { runtimeResult, usedTime, usedMemory, score });
	eventPublisher.publishEvent(new SubmissionEvent(this, submissionId, runtimeResult, message, true));
	
	LOGGER.info(String.format("Submission #%d judge completed and returned [%s] (Time = %d ms, Memory = %d KB, Score = %d).",
			new Object[] { submissionId, runtimeResult, usedTime, usedMemory, score }));
}
 
Example 7
Source File: Vendor.java    From chipster with MIT License 5 votes vote down vote up
public Order(MapMessage message) {
	this.orderNumber = nextOrderNumber++;
	this.message = message;
	try {
		this.quantity = message.getInt("Quantity");
	} catch (JMSException e) {
		e.printStackTrace();
		this.quantity = 0;
	}
	status = "Pending";
	pendingOrders.put(orderNumber, this);
}
 
Example 8
Source File: SampleMessageConverter.java    From tutorials with MIT License 4 votes vote down vote up
public Object fromMessage(Message message) throws JMSException, MessageConversionException {
    MapMessage mapMessage = (MapMessage) message;
    return new Employee(mapMessage.getString("name"), mapMessage.getInt("age"));
}