@Test(expected = NumberFormatException.class) public void testNonNumbers() throws Exception { OddOrEvenQueue function = new OddOrEvenQueue(); function.queueHandler("I'm Even", generateContext()); }
@FunctionName("OddOrEvenQueue") public void queueHandler( @QueueTrigger(name = "myNumber", queueName = "numbers", connection = "AzureWebJobsStorage") String myNumber, final ExecutionContext context ) throws NumberFormatException, ClientProtocolException, IOException { try { context.getLogger().info("Java Odd or Even Queue trigger function processed a message."); int number = Integer.parseInt(myNumber); if(number % 2 == 0) { context.getLogger().info("Was even"); HttpPost httpPost = new HttpPost("http: httpPost.setEntity(new StringEntity("Even")); CloseableHttpResponse response = client.execute(httpPost); response.close(); } else { context.getLogger().info("Was odd"); HttpPost httpPost = new HttpPost("http: httpPost.setEntity(new StringEntity("Odd")); CloseableHttpResponse response = client.execute(httpPost); } } catch(Exception e) { throw e; } finally { } }
OddOrEvenQueue { @FunctionName("OddOrEvenQueue") public void queueHandler( @QueueTrigger(name = "myNumber", queueName = "numbers", connection = "AzureWebJobsStorage") String myNumber, final ExecutionContext context ) throws NumberFormatException, ClientProtocolException, IOException { try { context.getLogger().info("Java Odd or Even Queue trigger function processed a message."); int number = Integer.parseInt(myNumber); if(number % 2 == 0) { context.getLogger().info("Was even"); HttpPost httpPost = new HttpPost("http: httpPost.setEntity(new StringEntity("Even")); CloseableHttpResponse response = client.execute(httpPost); response.close(); } else { context.getLogger().info("Was odd"); HttpPost httpPost = new HttpPost("http: httpPost.setEntity(new StringEntity("Odd")); CloseableHttpResponse response = client.execute(httpPost); } } catch(Exception e) { throw e; } finally { } } }
OddOrEvenQueue { @FunctionName("OddOrEvenQueue") public void queueHandler( @QueueTrigger(name = "myNumber", queueName = "numbers", connection = "AzureWebJobsStorage") String myNumber, final ExecutionContext context ) throws NumberFormatException, ClientProtocolException, IOException { try { context.getLogger().info("Java Odd or Even Queue trigger function processed a message."); int number = Integer.parseInt(myNumber); if(number % 2 == 0) { context.getLogger().info("Was even"); HttpPost httpPost = new HttpPost("http: httpPost.setEntity(new StringEntity("Even")); CloseableHttpResponse response = client.execute(httpPost); response.close(); } else { context.getLogger().info("Was odd"); HttpPost httpPost = new HttpPost("http: httpPost.setEntity(new StringEntity("Odd")); CloseableHttpResponse response = client.execute(httpPost); } } catch(Exception e) { throw e; } finally { } }  }
OddOrEvenQueue { @FunctionName("OddOrEvenQueue") public void queueHandler( @QueueTrigger(name = "myNumber", queueName = "numbers", connection = "AzureWebJobsStorage") String myNumber, final ExecutionContext context ) throws NumberFormatException, ClientProtocolException, IOException { try { context.getLogger().info("Java Odd or Even Queue trigger function processed a message."); int number = Integer.parseInt(myNumber); if(number % 2 == 0) { context.getLogger().info("Was even"); HttpPost httpPost = new HttpPost("http: httpPost.setEntity(new StringEntity("Even")); CloseableHttpResponse response = client.execute(httpPost); response.close(); } else { context.getLogger().info("Was odd"); HttpPost httpPost = new HttpPost("http: httpPost.setEntity(new StringEntity("Odd")); CloseableHttpResponse response = client.execute(httpPost); } } catch(Exception e) { throw e; } finally { } }  @FunctionName("OddOrEvenQueue") void queueHandler(
        @QueueTrigger(name = "myNumber", queueName = "numbers", connection = "AzureWebJobsStorage") String myNumber,
        final ExecutionContext context
    ); }
OddOrEvenQueue { @FunctionName("OddOrEvenQueue") public void queueHandler( @QueueTrigger(name = "myNumber", queueName = "numbers", connection = "AzureWebJobsStorage") String myNumber, final ExecutionContext context ) throws NumberFormatException, ClientProtocolException, IOException { try { context.getLogger().info("Java Odd or Even Queue trigger function processed a message."); int number = Integer.parseInt(myNumber); if(number % 2 == 0) { context.getLogger().info("Was even"); HttpPost httpPost = new HttpPost("http: httpPost.setEntity(new StringEntity("Even")); CloseableHttpResponse response = client.execute(httpPost); response.close(); } else { context.getLogger().info("Was odd"); HttpPost httpPost = new HttpPost("http: httpPost.setEntity(new StringEntity("Odd")); CloseableHttpResponse response = client.execute(httpPost); } } catch(Exception e) { throw e; } finally { } }  @FunctionName("OddOrEvenQueue") void queueHandler(
        @QueueTrigger(name = "myNumber", queueName = "numbers", connection = "AzureWebJobsStorage") String myNumber,
        final ExecutionContext context
    ); static CloseableHttpClient client; }