<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.7.0</version>
<executions>
<execution>
<id>schemas</id>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
<goal>protocol</goal>
<goal>idl-protocol</goal>
</goals>
<configuration>
<excludes>
<exclude>**/mapred/tether/**</exclude>
</excludes>
<sourceDirectory>${project.basedir}/src/main/avro/</sourceDirectory>
<outputDirectory>${project.basedir}/src/main/java/</outputDirectory>
<testSourceDirectory>${project.basedir}/src/test/avro/</testSourceDirectory>
<testOutputDirectory>${project.basedir}/src/test/java/</testOutputDirectory>
</configuration>
</execution>
</executions>
</plugin>
mvn compile
*Note*: integration with eclipse is very simple. Just type "mvn eclipse:eclipse" (see the "maven-eclipse-plugin":http://maven.apache.org/plugins/maven-eclipse-plugin/ documentation for more details).
h3. Running the Java sample
mvn -e exec:java -Dexec.mainClass=example.Main -Dexec.args='avro_user pat Hello_World'
h2. Python
h3. Requirements
Avro is "available from pypi":http://pypi.python.org/pypi/avro
It seems that the Avro python egg requires snappy.
sudo apt-get install libsnappy-dev
sudo pip install python-snappy
sudo pip install avro
h3. Python - start_server.py
Run this first to start the python avro Mail server.
# the MailResponder class implements the Mail protocol defined in mail.avpr
# main starts the server which implements the Mail service (Mail/MailResponder)
h3. Python - send_message.py
You'll see that the structure of the python code is similar to the java/ruby source.
src/main/python/send_message.py
# the main function takes three arguments; to, from and body of the message. After the server is started a Mail client is created, attached to the service, and used to send a "Message", the result of the RPC call is printed to the console.
h4. Run the python
From the src/main/python directory run:
./start_server.py
then in a separate shell run:
./send_message.py avro_user pat Hello_World
h2. Ruby
h3. Requirements
Install the "avro ruby gem":http://rubygems.org/gems/avro
sudo gem install avro
h3. Ruby - sample_ipc_server.rb
Run this first to start the ruby avro Mail server.
# the MailResponder class implements the Mail protocol defined in mail.avpr
# main starts the server which implements the Mail service (Mail/MailResponder)
h3. Ruby - sample_ipc_client.rb
You'll see that the structure of the ruby code is similar to the java/python source.
src/main/ruby/sample_ipc_client.rb
# the main function takes three arguments; to, from and body of the message. After the server is started a Mail client is created, attached to the service, and used to send a "Message", the result of the RPC call is printed to the console.
h4. Run the ruby
From the src/main/ruby directory run:
ruby -r 'rubygems' ./sample_ipc_server.rb
then in a separate shell run:
ruby -r 'rubygems' ./sample_ipc_client.rb avro_user pat Hello_World