List of usage examples for com.rabbitmq.client MapRpcServer MapRpcServer
public MapRpcServer(Channel channel, String queueName) throws IOException
From source file:org.s23m.cell.repository.client.server.RepositoryClientServer.java
License:Mozilla Public License
private MapRpcServer createRepositoryClientServer() throws IOException { final MapRpcServer server = new MapRpcServer(ch, QUEUE_NAME) { @Override/* w ww . j a v a 2 s .com*/ public Map<String, Object> handleMapCall(final Map<String, Object> request) { if (request.entrySet().iterator().hasNext()) { final String serializedArtifacts = request.entrySet().iterator().next().getValue().toString(); System.err.println("Got: " + serializedArtifacts); final Serializer sz = SerializerHolder.getS23MInstanceSerializer(SerializationType.XML); final ArtefactContainer artifacts = sz.unmarshallContainer(serializedArtifacts); final SerializationType typeOfService = SerializationType.valueOf(artifacts.getContentType()); System.err.println("Type: " + typeOfService); if (isGetOperation(typeOfService)) { final ArtefactContainer results = client.get(artifacts); final String serializedResults = sz.serializeContainer(results); return createResponseMessage(OK_PROMPT, serializedResults); //$NON-NLS-1$ } else { client.put(artifacts); return createResponseMessage(OK_PROMPT, null); //$NON-NLS-1$ } } else { return createResponseMessage("Missing artefact", "Missing artefact"); } } private boolean isGetOperation(final SerializationType typeOfService) { boolean isGetOp = false; switch (typeOfService) { case CONTAINMENT_TREE: isGetOp = true; break; case DEPENDENT_INSTANCES: isGetOp = true; break; case SEARCH_ARGUMENTS: isGetOp = true; break; default: throw new UnsupportedOperationException("This type is not yet supported"); } return isGetOp; } }; return server; }