@Test public void testCreateQueue() throws URISyntaxException { String queueName = "qrt_create_" + RandomStringUtils.randomAlphanumeric( 10 ); Map<String, Object> queueMap = new HashMap<String, Object>() {{ put("name", queueName); }}; Response response = target("queues").request() .post( Entity.entity( queueMap, MediaType.APPLICATION_JSON_TYPE)); Assert.assertEquals( 201, response.getStatus() ); URIStrategy uriStrategy = StartupListener.INJECTOR.getInstance( URIStrategy.class ); Assert.assertEquals( uriStrategy.queueURI( queueName ).toString(), response.getHeaderString( "location" ) ); response = target("queues").path( queueName ).path( "config" ).request().get(); Assert.assertEquals( 200, response.getStatus() ); ApiResponse apiResponse = response.readEntity( ApiResponse.class ); Assert.assertNotNull( apiResponse.getQueues() ); Assert.assertFalse( apiResponse.getQueues().isEmpty() ); Assert.assertEquals( 1, apiResponse.getQueues().size() ); Assert.assertEquals( queueName, apiResponse.getQueues().iterator().next().getName() ); response = target("queues").path( queueName ).queryParam( "confirm", true ).request().delete(); Assert.assertEquals( 200, response.getStatus() ); }
@POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public Response createQueue(Queue queue ) throws Exception { Preconditions.checkArgument(queue != null, "Queue configuration is required"); Preconditions.checkArgument(!QakkaUtils.isNullOrEmpty(queue.getName()), "Queue name is required"); queueManager.createQueue(queue); ApiResponse apiResponse = new ApiResponse(); apiResponse.setQueues( Collections.singletonList(queue) ); return Response.created( uriStrategy.queueURI( queue.getName() )).entity(apiResponse).build(); }
QueueResource { @POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public Response createQueue(Queue queue ) throws Exception { Preconditions.checkArgument(queue != null, "Queue configuration is required"); Preconditions.checkArgument(!QakkaUtils.isNullOrEmpty(queue.getName()), "Queue name is required"); queueManager.createQueue(queue); ApiResponse apiResponse = new ApiResponse(); apiResponse.setQueues( Collections.singletonList(queue) ); return Response.created( uriStrategy.queueURI( queue.getName() )).entity(apiResponse).build(); } }
QueueResource { @POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public Response createQueue(Queue queue ) throws Exception { Preconditions.checkArgument(queue != null, "Queue configuration is required"); Preconditions.checkArgument(!QakkaUtils.isNullOrEmpty(queue.getName()), "Queue name is required"); queueManager.createQueue(queue); ApiResponse apiResponse = new ApiResponse(); apiResponse.setQueues( Collections.singletonList(queue) ); return Response.created( uriStrategy.queueURI( queue.getName() )).entity(apiResponse).build(); } @Inject  QueueResource(
            QueueManager              queueManager,
            QueueMessageManager       queueMessageManager,
            URIStrategy               uriStrategy,
            Regions                   regions ); }
QueueResource { @POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public Response createQueue(Queue queue ) throws Exception { Preconditions.checkArgument(queue != null, "Queue configuration is required"); Preconditions.checkArgument(!QakkaUtils.isNullOrEmpty(queue.getName()), "Queue name is required"); queueManager.createQueue(queue); ApiResponse apiResponse = new ApiResponse(); apiResponse.setQueues( Collections.singletonList(queue) ); return Response.created( uriStrategy.queueURI( queue.getName() )).entity(apiResponse).build(); } @Inject  QueueResource(
            QueueManager              queueManager,
            QueueMessageManager       queueMessageManager,
            URIStrategy               uriStrategy,
            Regions                   regions ); @POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) Response createQueue(Queue queue ); @PUT @Path( "{queueName}/config" ) @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) Response updateQueueConfig( @PathParam("queueName") String queueName, Queue queue); @DELETE @Path( "{queueName}" ) @Produces({MediaType.APPLICATION_JSON}) Response deleteQueue( @PathParam("queueName") String queueName,
                                 @QueryParam("confirm") @DefaultValue("false") Boolean confirmedParam); @GET @Path( "{queueName}/config" ) @Produces({MediaType.APPLICATION_JSON}) Response getQueueConfig( @PathParam("queueName") String queueName); @GET @Produces({MediaType.APPLICATION_JSON}) List<String> getListOfQueues(); @GET @Path( "{queueName}/stats" ) @Produces({MediaType.APPLICATION_JSON}) Response getQueueStats( @PathParam("queueName") String queueName); @POST @Path( "{queueName}/messages" ) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response sendMessageJson(
            @PathParam("queueName")                     String queueName,
            @QueryParam("regions" )   @DefaultValue("") String regionsParam,
            @QueryParam("delay")      @DefaultValue("") String delayParam,
            @QueryParam("expiration") @DefaultValue("") String expirationParam,
                                                        String messageBody); @POST @Path( "{queueName}/messages" ) @Consumes(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_JSON) Response sendMessageBinary(
            @PathParam("queueName")                     String queueName,
            @QueryParam("regions" )   @DefaultValue("") String regionsParam,
            @QueryParam("delay")      @DefaultValue("") String delayParam,
            @QueryParam("expiration") @DefaultValue("") String expirationParam,
            @QueryParam("contentType")                  String actualContentType,
                                                        byte[] messageBody); @GET @Path( "{queueName}/messages" ) @Produces({MediaType.APPLICATION_JSON}) Response getNextMessages( @PathParam("queueName") String queueName,
                                     @QueryParam("count") @DefaultValue("1") String countParam); @DELETE @Path( "{queueName}/messages/{queueMessageId}" ) @Produces({MediaType.APPLICATION_JSON}) Response ackMessage( @PathParam("queueName") String queueName,
                                @PathParam("queueMessageId") String queueMessageId); @GET @Path( "{queueName}/data/{queueMessageId}" ) Response getMessageData(
            @PathParam("queueName") String queueName,
            @PathParam("queueMessageId") String queueMessageIdParam ); }
QueueResource { @POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) public Response createQueue(Queue queue ) throws Exception { Preconditions.checkArgument(queue != null, "Queue configuration is required"); Preconditions.checkArgument(!QakkaUtils.isNullOrEmpty(queue.getName()), "Queue name is required"); queueManager.createQueue(queue); ApiResponse apiResponse = new ApiResponse(); apiResponse.setQueues( Collections.singletonList(queue) ); return Response.created( uriStrategy.queueURI( queue.getName() )).entity(apiResponse).build(); } @Inject  QueueResource(
            QueueManager              queueManager,
            QueueMessageManager       queueMessageManager,
            URIStrategy               uriStrategy,
            Regions                   regions ); @POST @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) Response createQueue(Queue queue ); @PUT @Path( "{queueName}/config" ) @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) Response updateQueueConfig( @PathParam("queueName") String queueName, Queue queue); @DELETE @Path( "{queueName}" ) @Produces({MediaType.APPLICATION_JSON}) Response deleteQueue( @PathParam("queueName") String queueName,
                                 @QueryParam("confirm") @DefaultValue("false") Boolean confirmedParam); @GET @Path( "{queueName}/config" ) @Produces({MediaType.APPLICATION_JSON}) Response getQueueConfig( @PathParam("queueName") String queueName); @GET @Produces({MediaType.APPLICATION_JSON}) List<String> getListOfQueues(); @GET @Path( "{queueName}/stats" ) @Produces({MediaType.APPLICATION_JSON}) Response getQueueStats( @PathParam("queueName") String queueName); @POST @Path( "{queueName}/messages" ) @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response sendMessageJson(
            @PathParam("queueName")                     String queueName,
            @QueryParam("regions" )   @DefaultValue("") String regionsParam,
            @QueryParam("delay")      @DefaultValue("") String delayParam,
            @QueryParam("expiration") @DefaultValue("") String expirationParam,
                                                        String messageBody); @POST @Path( "{queueName}/messages" ) @Consumes(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_JSON) Response sendMessageBinary(
            @PathParam("queueName")                     String queueName,
            @QueryParam("regions" )   @DefaultValue("") String regionsParam,
            @QueryParam("delay")      @DefaultValue("") String delayParam,
            @QueryParam("expiration") @DefaultValue("") String expirationParam,
            @QueryParam("contentType")                  String actualContentType,
                                                        byte[] messageBody); @GET @Path( "{queueName}/messages" ) @Produces({MediaType.APPLICATION_JSON}) Response getNextMessages( @PathParam("queueName") String queueName,
                                     @QueryParam("count") @DefaultValue("1") String countParam); @DELETE @Path( "{queueName}/messages/{queueMessageId}" ) @Produces({MediaType.APPLICATION_JSON}) Response ackMessage( @PathParam("queueName") String queueName,
                                @PathParam("queueMessageId") String queueMessageId); @GET @Path( "{queueName}/data/{queueMessageId}" ) Response getMessageData(
            @PathParam("queueName") String queueName,
            @PathParam("queueMessageId") String queueMessageIdParam );  }