Skip to content

Instantly share code, notes, and snippets.

@cjmamo
cjmamo / Client.java
Last active December 11, 2015 03:48
SOAP over ZeroMQ with Apache CXF
package org.ossandme.client;
import org.apache.hello_world_soap_zmq.Greeter;
import org.apache.hello_world_soap_zmq.SOAPService;
public final class Client {
public static void doOperation() throws Exception {
// Create client
@cjmamo
cjmamo / Callback.java
Last active December 11, 2015 09:08
ReplyTo in ZeroMQ using WS-Addressing
package org.ossandme.client;
import javax.jws.WebParam;
import javax.jws.WebService;
import javax.xml.ws.RequestWrapper;
@WebService
public class Callback {
@RequestWrapper(localName = "sayHiResponse", targetNamespace = "http://apache.org/hello_world_soap_zmq/types")
@cjmamo
cjmamo / ApplicationController.java
Last active December 14, 2015 09:39
Posting & Processing JSON with jQuery & Spring MVC
...
@Controller
public class ApplicationController {
@RequestMapping(value = "/create-client", method = RequestMethod.GET)
public String getCreateClientForm() {
return "NewClientForm";
}
@RequestMapping(headers = "Content-Type=application/json", value = "submit-create-client", method = RequestMethod.POST)
@cjmamo
cjmamo / CommentResource.java
Last active April 24, 2018 18:15
How To Publish a WADL with Mule's REST Router Module
package org.ossandme;
import javax.ws.rs.*;
@Path("/{userid}/comments/{title}/feed")
public interface CommentResource {
@GET
public String retrieveComment(@PathParam("userid") String userID, @PathParam("title") String title);
@cjmamo
cjmamo / event(2).rb
Last active December 20, 2015 02:59
The Rails Way to Search Filtering
class Event < ActiveRecord::Base
attr_accessible :locality, :country, :date, :title, :tags
has_and_belongs_to_many :tags
def self.in_country(country)
if country.present?
where('country = ?', country)
else
scoped
@cjmamo
cjmamo / example(1).rb
Last active December 20, 2015 18:29
JRuby CXF: A Gem for Creating SOAP Web Services
class HelloWorld
def say_hello(name)
return 'Hello ' + name
end
def give_age(age)
return 'Your age is ' + age.to_s
end
@cjmamo
cjmamo / error
Last active December 21, 2015 06:18
JRuby Complex Classes in Java Method Signatures
NoMethodError: undefined method `start_with?' for #<Java::OrgJrubyAstJava_signature::ReferenceTypeNode:0x3b9fa8f7>
as_java_type at /opt/jruby-1.7.4/lib/ruby/shared/jruby/compiler/java_signature.rb:20
parameters at /opt/jruby-1.7.4/lib/ruby/shared/jruby/compiler/java_signature.rb:48
each at file:/opt/jruby-1.7.4/lib/jruby.jar!/jruby/java/java_ext/java.util.rb:7
map at org/jruby/RubyEnumerable.java:713
parameters at /opt/jruby-1.7.4/lib/ruby/shared/jruby/compiler/java_signature.rb:48
types at /opt/jruby-1.7.4/lib/ruby/shared/jruby/compiler/java_signature.rb:54
java_signature at /opt/jruby-1.7.4/lib/ruby/shared/jruby/core_ext/class.rb:44
Foo at lib/example.rb:12
(root) at lib/example.rb:11
@cjmamo
cjmamo / bridge.cs
Last active December 21, 2015 18:09
Bridging Mule and MSMQ with ZeroMQ
using System;
using System.Text;
using ZeroMQ;
using System.Messaging;
namespace ConsoleApplication
{
class Bridge
{
static void Main(string[] args)
@cjmamo
cjmamo / MyConsumer.java
Last active June 6, 2016 02:02
Apache Kafka for Event Sourcing
...
public class MyConsumer {
private static final int SO_TIMEOUT = 100000; // socket timeout
private static final int BUFFER_SIZE = 64 * 1024; // maximum socket receive buffer in bytes
private static final int FETCH_SIZE = 100000; // maximum bytes to fetch from topic
public static void main(String args[]) {
MyConsumer myConsumer = new MyConsumer();
@cjmamo
cjmamo / AhcProcessor(1).java
Last active January 2, 2016 10:19
Scaling up Mule with Async Request Handling/Continuations
package org.ossandme;
...
// Naive implementation
public class AhcProcessor extends AbstractInterceptingMessageProcessor {
@Override
public MuleEvent process(final MuleEvent event) throws MuleException {
...