forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial commit of samples branch * Updating readme to include up-to-date roadmap * Changing folder structure, and adding samples... * Removing old sample files * updating readme to be more clear on roadmap * Updating connection string name * Copying .gitignore from Azure Java SDk https://github.com/Azure/azure-sdk-for-java/blob/master/.gitignore * Removing ignored files * Mistakenly added IllegalEntityException in last merge
- Loading branch information
Showing
84 changed files
with
195 additions
and
104 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,53 @@ | ||
### Eclipse ### | ||
*.class | ||
|
||
#External libs | ||
extlib/ | ||
|
||
# Auth files | ||
*.auth | ||
*.azureauth | ||
|
||
# Local checkstyle | ||
*.checkstyle | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.ear | ||
|
||
# Azure Tooling # | ||
node_modules | ||
packages | ||
|
||
# Eclipse # | ||
*.pydevproject | ||
.project | ||
.metadata | ||
bin/ | ||
tmp/ | ||
bin/** | ||
tmp/** | ||
tmp/**/* | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.classpath | ||
.settings/ | ||
.loadpath | ||
.recommenders | ||
|
||
# Eclipse Core | ||
.project | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# PyDev specific (Python IDE for Eclipse) | ||
*.pydevproject | ||
|
||
# CDT-specific (C/C++ Development Tooling) | ||
.cproject | ||
|
||
# JDT-specific (Eclipse Java Development Tools) | ||
# Other Tooling # | ||
.classpath | ||
.project | ||
target | ||
.idea | ||
*.iml | ||
|
||
# Java annotation processor (APT) | ||
.factorypath | ||
|
||
# PDT-specific (PHP Development Tools) | ||
.buildpath | ||
|
||
# sbteclipse plugin | ||
.target | ||
|
||
# Tern plugin | ||
.tern-project | ||
|
||
# TeXlipse plugin | ||
.texlipse | ||
|
||
# STS (Spring Tool Suite) | ||
.springBeans | ||
# Mac OS # | ||
.DS_Store | ||
.DS_Store? | ||
|
||
# Code Recommenders | ||
.recommenders/ | ||
# Windows # | ||
Thumbs.db |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>azure-servicebus-samples</groupId> | ||
<artifactId>azure-servicebus-samples</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<build> | ||
<sourceDirectory>src</sourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.5.1</version> | ||
<configuration> | ||
<source/> | ||
<target/> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.qpid</groupId> | ||
<artifactId>proton-j</artifactId> | ||
<version>0.13.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bouncycastle</groupId> | ||
<artifactId>bcpkix-jdk15on</artifactId> | ||
<version>1.49</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
41 changes: 41 additions & 0 deletions
41
azure-servicebus-samples/src/com/microsoft/azure/servicebus/samples/ReceiveSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.microsoft.azure.servicebus.samples; | ||
|
||
import java.time.Duration; | ||
|
||
import com.microsoft.azure.servicebus.ClientFactory; | ||
import com.microsoft.azure.servicebus.IBrokeredMessage; | ||
import com.microsoft.azure.servicebus.IMessageReceiver; | ||
import com.microsoft.azure.servicebus.ReceiveMode; | ||
import com.microsoft.azure.servicebus.primitives.ConnectionStringBuilder; | ||
import com.microsoft.azure.servicebus.primitives.ServiceBusException; | ||
|
||
public class ReceiveSample { | ||
|
||
private static final String ENVIRONMENT_VARIABLE_NAME = "azure-service-bus-java/connectionstring"; | ||
private static IMessageReceiver receiver; | ||
|
||
public static void main(String[] args) throws Exception { | ||
System.out.println("Begining receive sample."); | ||
|
||
String envVar = System.getenv(ENVIRONMENT_VARIABLE_NAME); | ||
|
||
if (envVar.isEmpty()) { | ||
throw new Exception("Could not read environment variable: " + ENVIRONMENT_VARIABLE_NAME); | ||
} | ||
|
||
ConnectionStringBuilder csb = new ConnectionStringBuilder(envVar); | ||
receiver = ClientFactory.createMessageReceiverFromConnectionStringBuilder(csb, ReceiveMode.PeekLock); | ||
|
||
receiveMessages(); | ||
System.out.println("Receive sample completed."); | ||
} | ||
|
||
private static void receiveMessages() throws InterruptedException, ServiceBusException { | ||
while (true) { | ||
IBrokeredMessage receivedMessage = receiver.receive(Duration.ofMinutes(1)); | ||
System.out.println(new String(receivedMessage.getContent())); | ||
receiver.complete(receivedMessage); | ||
} | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
azure-servicebus-samples/src/com/microsoft/azure/servicebus/samples/SendSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.microsoft.azure.servicebus.samples; | ||
|
||
import com.microsoft.azure.servicebus.BrokeredMessage; | ||
import com.microsoft.azure.servicebus.ClientFactory; | ||
import com.microsoft.azure.servicebus.IMessageSender; | ||
import com.microsoft.azure.servicebus.primitives.ConnectionStringBuilder; | ||
import com.microsoft.azure.servicebus.primitives.ServiceBusException; | ||
|
||
public class SendSample { | ||
|
||
private static final String ENVIRONMENT_VARIABLE_NAME = "azure-service-bus-java/connectionstring"; | ||
private static final int NUMBER_OF_MESSAGES = 1; | ||
private static IMessageSender sender; | ||
|
||
public static void main(String[] args) throws Exception { | ||
System.out.println("Begining send sample."); | ||
|
||
String envVar = System.getenv(ENVIRONMENT_VARIABLE_NAME); | ||
|
||
if (envVar.isEmpty()) { | ||
throw new Exception("Could not read environment variable: " + ENVIRONMENT_VARIABLE_NAME); | ||
} | ||
|
||
ConnectionStringBuilder csb = new ConnectionStringBuilder(envVar); | ||
sender = ClientFactory.createMessageSenderFromConnectionStringBuilder(csb); | ||
|
||
sendMessages(NUMBER_OF_MESSAGES); | ||
System.out.println("Send sample completed."); | ||
} | ||
|
||
private static void sendMessages(int numMessages) throws InterruptedException, ServiceBusException { | ||
for(int i = 0; i < numMessages; i ++) { | ||
String messageBody = "MessageNumber: " + i; | ||
BrokeredMessage message = new BrokeredMessage(messageBody.getBytes()); | ||
sender.send(message); | ||
System.out.println("Sending message " + i); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespacename=yournamespace | ||
entitypath=yourentitypath | ||
sharedaccesskeyname=yoursharedaccesskey | ||
sharedaccesskey=yoursharedaccesskey |
File renamed without changes.
File renamed without changes.
File renamed without changes.