Implement Validate message reply seq ids
diff --git a/compiler/cpp/src/thrift/generate/t_rb_generator.cc b/compiler/cpp/src/thrift/generate/t_rb_generator.cc
index 90dbfe5..17e57cf 100644
--- a/compiler/cpp/src/thrift/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_rb_generator.cc
@@ -944,7 +944,12 @@
       f_service_.indent() << "def " << function_signature(&recv_function) << endl;
       f_service_.indent_up();
 
-      // TODO(mcslee): Validate message reply here, seq ids etc.
+      f_service_.indent() << "fname, mtype, rseqid = receive_message_begin()" << endl;
+      f_service_.indent() << "handle_exception(mtype)" << endl;
+
+      f_service_.indent() << "if reply_seqid(rseqid)==false" << endl;
+      f_service_.indent() << "  raise \"seqid reply faild\"" << endl;
+      f_service_.indent() << "end" << endl;
 
       f_service_.indent() << "result = receive_message(" << resultname << ")" << endl;
 
diff --git a/lib/rb/lib/thrift/client.rb b/lib/rb/lib/thrift/client.rb
index 64ef059..5c7cd98 100644
--- a/lib/rb/lib/thrift/client.rb
+++ b/lib/rb/lib/thrift/client.rb
@@ -50,9 +50,17 @@
       @oprot.trans.flush
     end
 
-    def receive_message(result_klass)
+    def receive_message_begin()
       fname, mtype, rseqid = @iprot.read_message_begin
-      handle_exception(mtype)
+      [fname, mtype, rseqid]
+    end
+
+    def reply_seqid(rseqid)
+     result = (rseqid==@seqid)?true:false
+     result
+    end
+
+    def receive_message(result_klass)
       result = result_klass.new
       result.read(@iprot)
       @iprot.read_message_end
diff --git a/lib/rb/spec/client_spec.rb b/lib/rb/spec/client_spec.rb
index d5d4cee..f015d66 100644
--- a/lib/rb/spec/client_spec.rb
+++ b/lib/rb/spec/client_spec.rb
@@ -69,6 +69,7 @@
       expect(@prot).to receive(:read_message_end)
       mock_klass = double("#<MockClass:mock>")
       expect(mock_klass).to receive(:read).with(@prot)
+      @client.receive_message_begin()
       @client.receive_message(double("MockClass", :new => mock_klass))
     end
 
@@ -80,7 +81,8 @@
           expect(mock_exc).to receive(:read).with(@prot)
         end
       end
-      expect { @client.receive_message(nil) }.to raise_error(StandardError)
+      fname, mtype, sqeid = @client.receive_message_begin()
+      expect { @client.handle_exception(mtype) }.to raise_error(StandardError)
     end
 
     it "should close the transport if an error occurs while sending a message" do