Oracle Inter-Session Communication

Oren Nakdimon
Oren NakdimonDatabase Expert at Moovit
Oracle Inter-Session
Communication
Oren Nakdimon
www.db-oriented.com
 oren@db-oriented.com
 +972-54-4393763
@DBoriented
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
http://db-oriented.com
Who Am
I?
INTER-SESSION COMMUNICATION
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session Session
Session
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session Session
Session
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session
SGA
Session
Session
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session
SGA
Session
Session
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session
Outbox
SGA
Inbox
Session
Session
Outbox
Inbox Outbox
Inbox
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session
Outbox
SGA
Inbox
Session
Session
Outbox
Inbox Outbox
Inbox
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session
Outbox
SGA
Inbox
Session
Session
Outbox
Inbox Outbox
Inbox
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session
Outbox
SGA
Session
Outbox
Inbox
Session
Inbox Outbox
Inbox
Outbox
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session
Outbox
SGA
Session
Outbox
Inbox
Session
Inbox Outbox
Inbox
Outbox Inbox
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session
Session
Outbox
SGA
Session
Outbox
Inbox
Inbox Outbox
Outbox
Outbox Inbox
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session
Session
Outbox
SGA
Session
Outbox
Inbox
Inbox Outbox
Outbox
Outbox Inbox
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session
Session
Outbox
SGA
Session
Outbox
Inbox
Inbox Outbox
Outbox
Outbox Inbox
DEMO
Logger
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package pipe_demo as
procedure log(i_text in varchar2);
procedure get_next
(
o_user out varchar2,
o_sid out number,
o_host out varchar2,
o_time out date,
o_text out varchar2
);
end pipe_demo;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package pipe_demo as
procedure log(i_text in varchar2);
procedure get_next
(
o_user out varchar2,
o_sid out number,
o_host out varchar2,
o_time out date,
o_text out varchar2
);
end pipe_demo;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package pipe_demo as
procedure log(i_text in varchar2);
procedure get_next
(
o_user out varchar2,
o_sid out number,
o_host out varchar2,
o_time out date,
o_text out varchar2
);
end pipe_demo;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package body pipe_demo as
c_log_pipe constant varchar2(13) := 'DEMO_LOG_PIPE';
procedure log(i_text in varchar2) is
l_status number;
begin
dbms_pipe.pack_message(user);
dbms_pipe.pack_message(to_number(sys_context('userenv', 'sid')));
dbms_pipe.pack_message(sys_context('userenv', 'host'));
dbms_pipe.pack_message(sysdate);
dbms_pipe.pack_message(i_text);
l_status := dbms_pipe.send_message(c_log_pipe);
if l_status != 0 then
raise_application_error(-20000,
'dbms_pipe.send_message failed with status ' || l_status);
end if;
end log;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package body pipe_demo as
c_log_pipe constant varchar2(13) := 'DEMO_LOG_PIPE';
procedure log(i_text in varchar2) is
l_status number;
begin
dbms_pipe.pack_message(user);
dbms_pipe.pack_message(to_number(sys_context('userenv', 'sid')));
dbms_pipe.pack_message(sys_context('userenv', 'host'));
dbms_pipe.pack_message(sysdate);
dbms_pipe.pack_message(i_text);
l_status := dbms_pipe.send_message(c_log_pipe);
if l_status != 0 then
raise_application_error(-20000,
'dbms_pipe.send_message failed with status ' || l_status);
end if;
end log;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package body pipe_demo as
c_log_pipe constant varchar2(13) := 'DEMO_LOG_PIPE';
procedure log(i_text in varchar2) is
l_status number;
begin
dbms_pipe.pack_message(user);
dbms_pipe.pack_message(to_number(sys_context('userenv', 'sid')));
dbms_pipe.pack_message(sys_context('userenv', 'host'));
dbms_pipe.pack_message(sysdate);
dbms_pipe.pack_message(i_text);
l_status := dbms_pipe.send_message(c_log_pipe);
if l_status != 0 then
raise_application_error(-20000,
'dbms_pipe.send_message failed with status ' || l_status);
end if;
end log;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package body pipe_demo as
c_log_pipe constant varchar2(13) := 'DEMO_LOG_PIPE';
procedure log(i_text in varchar2) is
l_status number;
begin
dbms_pipe.pack_message(user);
dbms_pipe.pack_message(to_number(sys_context('userenv', 'sid')));
dbms_pipe.pack_message(sys_context('userenv', 'host'));
dbms_pipe.pack_message(sysdate);
dbms_pipe.pack_message(i_text);
l_status := dbms_pipe.send_message(c_log_pipe);
if l_status != 0 then
raise_application_error(-20000,
'dbms_pipe.send_message failed with status ' || l_status);
end if;
end log;
pack_message (number)
pack_message (varchar2)
pack_message (date)
pack_message_raw
pack_message_rowid
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package body pipe_demo as
c_log_pipe constant varchar2(13) := 'DEMO_LOG_PIPE';
procedure log(i_text in varchar2) is
l_status number;
begin
dbms_pipe.pack_message(user);
dbms_pipe.pack_message(to_number(sys_context('userenv', 'sid')));
dbms_pipe.pack_message(sys_context('userenv', 'host'));
dbms_pipe.pack_message(sysdate);
dbms_pipe.pack_message(i_text);
l_status := dbms_pipe.send_message(c_log_pipe);
if l_status != 0 then
raise_application_error(-20000,
'dbms_pipe.send_message failed with status ' || l_status);
end if;
end log;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
procedure get_next
(
o_user out varchar2,
o_sid out number,
o_host out varchar2,
o_time out date,
o_text out varchar2
) is
l_status number;
begin
l_status := dbms_pipe.receive_message(pipename => c_log_pipe);
if l_status != 0 then
raise_application_error(-20000,
'dbms_pipe.receive_message failed with status ' || l_status);
end if;
dbms_pipe.unpack_message(o_user);
dbms_pipe.unpack_message(o_sid);
dbms_pipe.unpack_message(o_host);
dbms_pipe.unpack_message(o_time);
dbms_pipe.unpack_message(o_text);
end get_next;
end pipe_demo;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
procedure get_next
(
o_user out varchar2,
o_sid out number,
o_host out varchar2,
o_time out date,
o_text out varchar2
) is
l_status number;
begin
l_status := dbms_pipe.receive_message(pipename => c_log_pipe);
if l_status != 0 then
raise_application_error(-20000,
'dbms_pipe.receive_message failed with status ' || l_status);
end if;
dbms_pipe.unpack_message(o_user);
dbms_pipe.unpack_message(o_sid);
dbms_pipe.unpack_message(o_host);
dbms_pipe.unpack_message(o_time);
dbms_pipe.unpack_message(o_text);
end get_next;
end pipe_demo;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
procedure get_next
(
o_user out varchar2,
o_sid out number,
o_host out varchar2,
o_time out date,
o_text out varchar2
) is
l_status number;
begin
l_status := dbms_pipe.receive_message(pipename => c_log_pipe);
if l_status != 0 then
raise_application_error(-20000,
'dbms_pipe.receive_message failed with status ' || l_status);
end if;
dbms_pipe.unpack_message(o_user);
dbms_pipe.unpack_message(o_sid);
dbms_pipe.unpack_message(o_host);
dbms_pipe.unpack_message(o_time);
dbms_pipe.unpack_message(o_text);
end get_next;
end pipe_demo;
unpack_message (number)
unpack_message (varchar2)
unpack_message (date)
unpack_message_raw
unpack_message_rowid
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
public class Logger {
public static void main(String args[]) throws SQLException {
Properties info = new Properties();
info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER);
info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD);
OracleDataSource ods = new OracleDataSource();
ods.setURL(DB_URL);
ods.setConnectionProperties(info);
try (OracleConnection connection = (OracleConnection) ods.getConnection()) {
DatabaseMetaData dbmd = connection.getMetaData();
System.out.println("Ready...");
System.out.println();
System.out.println("Time Host User SID Message");
System.out.println("--------------- -------------- ----- --- -------");
processRequests(connection);
System.out.println("Bye!");
System.out.println();
}
}
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
public class Logger {
public static void main(String args[]) throws SQLException {
Properties info = new Properties();
info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER);
info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD);
OracleDataSource ods = new OracleDataSource();
ods.setURL(DB_URL);
ods.setConnectionProperties(info);
try (OracleConnection connection = (OracleConnection) ods.getConnection()) {
DatabaseMetaData dbmd = connection.getMetaData();
System.out.println("Ready...");
System.out.println();
System.out.println("Time Host User SID Message");
System.out.println("--------------- -------------- ----- --- -------");
processRequests(connection);
System.out.println("Bye!");
System.out.println();
}
}
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
public class Logger {
public static void main(String args[]) throws SQLException {
Properties info = new Properties();
info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER);
info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD);
OracleDataSource ods = new OracleDataSource();
ods.setURL(DB_URL);
ods.setConnectionProperties(info);
try (OracleConnection connection = (OracleConnection) ods.getConnection()) {
DatabaseMetaData dbmd = connection.getMetaData();
System.out.println("Ready...");
System.out.println();
System.out.println("Time Host User SID Message");
System.out.println("--------------- -------------- ----- --- -------");
processRequests(connection);
System.out.println("Bye!");
System.out.println();
}
}
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
public class Logger {
public static void main(String args[]) throws SQLException {
Properties info = new Properties();
info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER);
info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD);
OracleDataSource ods = new OracleDataSource();
ods.setURL(DB_URL);
ods.setConnectionProperties(info);
try (OracleConnection connection = (OracleConnection) ods.getConnection()) {
DatabaseMetaData dbmd = connection.getMetaData();
System.out.println("Ready...");
System.out.println();
System.out.println("Time Host User SID Message");
System.out.println("--------------- -------------- ----- --- -------");
processRequests(connection);
System.out.println("Bye!");
System.out.println();
}
}
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
public static void processRequests(Connection connection) throws SQLException {
String user;
int sid;
String host;
Timestamp time;
String text = " ";
CallableStatement callableStatement =
connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }");
callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(2, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(4, java.sql.Types.DATE);
callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR);
do {
callableStatement.executeUpdate();
user = callableStatement.getString(1);
sid = callableStatement.getInt(2);
host = callableStatement.getString(3);
time = callableStatement.getTimestamp(4);
text = callableStatement.getString(5);
System.out.println(time + " " + host + " " + user + " " + String.format("%3s",
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
public static void processRequests(Connection connection) throws SQLException {
String user;
int sid;
String host;
Timestamp time;
String text = " ";
CallableStatement callableStatement =
connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }");
callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(2, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(4, java.sql.Types.DATE);
callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR);
do {
callableStatement.executeUpdate();
user = callableStatement.getString(1);
sid = callableStatement.getInt(2);
host = callableStatement.getString(3);
time = callableStatement.getTimestamp(4);
text = callableStatement.getString(5);
System.out.println(time + " " + host + " " + user + " " + String.format("%3s",
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
public static void processRequests(Connection connection) throws SQLException {
String user;
int sid;
String host;
Timestamp time;
String text = " ";
CallableStatement callableStatement =
connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }");
callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(2, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(4, java.sql.Types.DATE);
callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR);
do {
callableStatement.executeUpdate();
user = callableStatement.getString(1);
sid = callableStatement.getInt(2);
host = callableStatement.getString(3);
time = callableStatement.getTimestamp(4);
text = callableStatement.getString(5);
System.out.println(time + " " + host + " " + user + " " + String.format("%3s",
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
CallableStatement callableStatement =
connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }");
callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(2, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(4, java.sql.Types.DATE);
callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR);
do {
callableStatement.executeUpdate();
user = callableStatement.getString(1);
sid = callableStatement.getInt(2);
host = callableStatement.getString(3);
time = callableStatement.getTimestamp(4);
text = callableStatement.getString(5);
System.out.println(time + " " + host + " " + user + " " + String.format("%3s",
sid) + " " + text);
} while (!text.equals("ABORT"));
callableStatement.close();
}
}
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
CallableStatement callableStatement =
connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }");
callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(2, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(4, java.sql.Types.DATE);
callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR);
do {
callableStatement.executeUpdate();
user = callableStatement.getString(1);
sid = callableStatement.getInt(2);
host = callableStatement.getString(3);
time = callableStatement.getTimestamp(4);
text = callableStatement.getString(5);
System.out.println(time + " " + host + " " + user + " " + String.format("%3s",
sid) + " " + text);
} while (!text.equals("ABORT"));
callableStatement.close();
}
}
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
CallableStatement callableStatement =
connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }");
callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(2, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(4, java.sql.Types.DATE);
callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR);
do {
callableStatement.executeUpdate();
user = callableStatement.getString(1);
sid = callableStatement.getInt(2);
host = callableStatement.getString(3);
time = callableStatement.getTimestamp(4);
text = callableStatement.getString(5);
System.out.println(time + " " + host + " " + user + " " + String.format("%3s",
sid) + " " + text);
} while (!text.equals("ABORT"));
callableStatement.close();
}
}
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
CallableStatement callableStatement =
connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }");
callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(2, java.sql.Types.INTEGER);
callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR);
callableStatement.registerOutParameter(4, java.sql.Types.DATE);
callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR);
do {
callableStatement.executeUpdate();
user = callableStatement.getString(1);
sid = callableStatement.getInt(2);
host = callableStatement.getString(3);
time = callableStatement.getTimestamp(4);
text = callableStatement.getString(5);
System.out.println(time + " " + host + " " + user + " " + String.format("%3s",
sid) + " " + text);
} while (!text.equals("ABORT"));
callableStatement.close();
}
}
PIPES
A Single Consumer
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
SGA
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
SGA
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
SGA
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
PIPES
Multiple Consumers
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
SGA
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
DEMO
Multiple Consumers
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package pipe_demo as
procedure log(i_text in varchar2);
procedure get_next
(
o_user out varchar2,
o_sid out number,
o_host out varchar2,
o_time out date,
o_text out varchar2
);
procedure send_many_logs
(
i_text in varchar2,
i_how_many in binary_integer
);
end pipe_demo;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package body pipe_demo as
...
procedure send_many_logs
(
i_text in varchar2,
i_how_many in binary_integer
) is
c_alert_name constant varchar2(10) := 'DEMO_ALERT';
l_message varchar2(100);
l_status number;
begin
dbms_alert.register(c_alert_name);
dbms_alert.waitone(c_alert_name, l_message, l_status);
for i in 1 .. i_how_many
loop
pipe_demo.log(i_text || '# ' || to_char(i));
end loop;
dbms_alert.remove(c_alert_name);
end send_many_logs;
end pipe_demo;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package body pipe_demo as
...
procedure send_many_logs
(
i_text in varchar2,
i_how_many in binary_integer
) is
c_alert_name constant varchar2(10) := 'DEMO_ALERT';
l_message varchar2(100);
l_status number;
begin
dbms_alert.register(c_alert_name);
dbms_alert.waitone(c_alert_name, l_message, l_status);
for i in 1 .. i_how_many
loop
pipe_demo.log(i_text || '# ' || to_char(i));
end loop;
dbms_alert.remove(c_alert_name);
end send_many_logs;
end pipe_demo;
ALERTS (SIGNALS)
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
Session
Session
Session
Session
Session
Session
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package body pipe_demo as
...
procedure send_many_logs
(
i_text in varchar2,
i_how_many in binary_integer
) is
c_alert_name constant varchar2(10) := 'DEMO_ALERT';
l_message varchar2(100);
l_status number;
begin
dbms_alert.register(c_alert_name);
dbms_alert.waitone(c_alert_name, l_message, l_status);
for i in 1 .. i_how_many
loop
pipe_demo.log(i_text || '# ' || to_char(i));
end loop;
dbms_alert.remove(c_alert_name);
end send_many_logs;
end pipe_demo;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package body pipe_demo as
...
procedure send_many_logs
(
i_text in varchar2,
i_how_many in binary_integer
) is
c_alert_name constant varchar2(10) := 'DEMO_ALERT';
l_message varchar2(100);
l_status number;
begin
dbms_alert.register(c_alert_name);
dbms_alert.waitone(c_alert_name, l_message, l_status);
for i in 1 .. i_how_many
loop
pipe_demo.log(i_text || '# ' || to_char(i));
end loop;
dbms_alert.remove(c_alert_name);
end send_many_logs;
end pipe_demo;
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package body pipe_demo as
...
procedure send_many_logs
(
i_text in varchar2,
i_how_many in binary_integer
) is
c_alert_name constant varchar2(10) := 'DEMO_ALERT';
l_message varchar2(100);
l_status number;
begin
dbms_alert.register(c_alert_name);
dbms_alert.waitone(c_alert_name, l_message, l_status);
for i in 1 .. i_how_many
loop
pipe_demo.log(i_text || '# ' || to_char(i));
end loop;
dbms_alert.remove(c_alert_name);
end send_many_logs;
end pipe_demo;
There is also dbms_alert.waitany
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
create or replace package body pipe_demo as
...
procedure send_many_logs
(
i_text in varchar2,
i_how_many in binary_integer
) is
c_alert_name constant varchar2(10) := 'DEMO_ALERT';
l_message varchar2(100);
l_status number;
begin
dbms_alert.register(c_alert_name);
dbms_alert.waitone(c_alert_name, l_message, l_status);
for i in 1 .. i_how_many
loop
pipe_demo.log(i_text || '# ' || to_char(i));
end loop;
dbms_alert.remove(c_alert_name);
end send_many_logs;
end pipe_demo; There is also dbms_alert.removeall
PIPES
Request and Response
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
SGA
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
SGA
Session
Inbox Outbox
Session
Inbox Outbox
Session
Inbox Outbox
dbms_pipe.unique_session_name
This presentation is available in http://db-oriented.com/presentations
©
Oren
Nakdimon
©
Oren
Nakdimon
DBMS_PIPE DBMS_ALERT
Type Named Pipes / Queue Signals / Broadcast
Implementation SGA structure Table
Transactional? Non-Transactional Transactional
Consumers of a specific
message
Single Consumer Zero-to-Multiple Consumers
Blocked Publisher? When pipe is full (“pipe put”
wait event)
When other session signaled
to the same alert and hasn’t
committed yet (TX lock), but
only if there are registered
consumers
Possible Loss of Messages? Instance crash/shutdown Multiple signals to the same
alert before read by the
consumer
THANK YOU
Oren Nakdimon
www.db-oriented.com
 oren@db-oriented.com
 +972-54-4393763
@DBoriented
1 of 60

Recommended

Constraint Optimization by
Constraint OptimizationConstraint Optimization
Constraint OptimizationOren Nakdimon
1.4K views106 slides
Indexes and Indexing in Oracle 12c by
Indexes and Indexing in Oracle 12cIndexes and Indexing in Oracle 12c
Indexes and Indexing in Oracle 12cOren Nakdimon
3.1K views29 slides
Oren nakdimon oh really... i didn't know it is supported in standard edition by
Oren nakdimon   oh really... i didn't know it is supported in standard editionOren nakdimon   oh really... i didn't know it is supported in standard edition
Oren nakdimon oh really... i didn't know it is supported in standard editionOren Nakdimon
2.3K views91 slides
Edition Based Redefinition Made Easy - Oren Nakdimon by
Edition Based Redefinition Made Easy - Oren NakdimonEdition Based Redefinition Made Easy - Oren Nakdimon
Edition Based Redefinition Made Easy - Oren NakdimonOren Nakdimon
1.9K views166 slides
How to upgrade your application with no downtime (using edition-based redefin... by
How to upgrade your application with no downtime (using edition-based redefin...How to upgrade your application with no downtime (using edition-based redefin...
How to upgrade your application with no downtime (using edition-based redefin...Oren Nakdimon
2.7K views52 slides
Write Less (code) With More (Oracle Database 12c New Features) by
Write Less (code) With More (Oracle Database 12c New Features)Write Less (code) With More (Oracle Database 12c New Features)
Write Less (code) With More (Oracle Database 12c New Features)Oren Nakdimon
2.5K views50 slides

More Related Content

What's hot

New PLSQL in Oracle Database 12c by
New PLSQL in Oracle Database 12cNew PLSQL in Oracle Database 12c
New PLSQL in Oracle Database 12cConnor McDonald
152 views68 slides
DBMS_SQL by
DBMS_SQLDBMS_SQL
DBMS_SQLMahesh Vallampati
1K views6 slides
MODELS'16 - RESTalk by
MODELS'16 - RESTalkMODELS'16 - RESTalk
MODELS'16 - RESTalkAna Ivanchikj
496 views42 slides
Firebird 3 Windows Functions by
Firebird 3 Windows  FunctionsFirebird 3 Windows  Functions
Firebird 3 Windows FunctionsMind The Firebird
3.7K views34 slides
JAX-RS and CDI Bike the (Reactive) Bridge by
JAX-RS and CDI Bike the (Reactive) BridgeJAX-RS and CDI Bike the (Reactive) Bridge
JAX-RS and CDI Bike the (Reactive) BridgeJosé Paumard
1.2K views48 slides
PL/SQL Fundamentals I by
PL/SQL Fundamentals IPL/SQL Fundamentals I
PL/SQL Fundamentals INick Buytaert
16.8K views56 slides

What's hot(14)

Similar to Oracle Inter-Session Communication

Plsql by
PlsqlPlsql
Plsqlfika sweety
5.2K views31 slides
Performance measurement and tuning by
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuningAOE
2.3K views99 slides
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit by
Penetration Testing for Easy RM to MP3 Converter Application and Post ExploitPenetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Penetration Testing for Easy RM to MP3 Converter Application and Post ExploitJongWon Kim
1.6K views21 slides
Write Less (Code) With More (Features) [UKOUG 22] by
Write Less (Code) With More (Features) [UKOUG 22]Write Less (Code) With More (Features) [UKOUG 22]
Write Less (Code) With More (Features) [UKOUG 22]Oren Nakdimon
35 views116 slides
Real-Time Query for Data Guard by
Real-Time Query for Data Guard Real-Time Query for Data Guard
Real-Time Query for Data Guard Uwe Hesse
3.5K views25 slides
Distributed Applications with Perl & Gearman by
Distributed Applications with Perl & GearmanDistributed Applications with Perl & Gearman
Distributed Applications with Perl & GearmanIssac Goldstand
4.6K views24 slides

Similar to Oracle Inter-Session Communication(20)

Performance measurement and tuning by AOE
Performance measurement and tuningPerformance measurement and tuning
Performance measurement and tuning
AOE2.3K views
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit by JongWon Kim
Penetration Testing for Easy RM to MP3 Converter Application and Post ExploitPenetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
JongWon Kim1.6K views
Write Less (Code) With More (Features) [UKOUG 22] by Oren Nakdimon
Write Less (Code) With More (Features) [UKOUG 22]Write Less (Code) With More (Features) [UKOUG 22]
Write Less (Code) With More (Features) [UKOUG 22]
Oren Nakdimon35 views
Real-Time Query for Data Guard by Uwe Hesse
Real-Time Query for Data Guard Real-Time Query for Data Guard
Real-Time Query for Data Guard
Uwe Hesse3.5K views
Distributed Applications with Perl & Gearman by Issac Goldstand
Distributed Applications with Perl & GearmanDistributed Applications with Perl & Gearman
Distributed Applications with Perl & Gearman
Issac Goldstand4.6K views
Study2study#4 nginx conf_1_24 by Naoya Nakazawa
Study2study#4 nginx conf_1_24Study2study#4 nginx conf_1_24
Study2study#4 nginx conf_1_24
Naoya Nakazawa823 views
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016) by James Titcumb
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
James Titcumb694 views
Dolibarr - information for developers and partners - devcamp Pau 2019 by Laurent Destailleur
Dolibarr - information for developers and partners - devcamp Pau 2019Dolibarr - information for developers and partners - devcamp Pau 2019
Dolibarr - information for developers and partners - devcamp Pau 2019
Container orchestration from theory to practice by Docker, Inc.
Container orchestration from theory to practiceContainer orchestration from theory to practice
Container orchestration from theory to practice
Docker, Inc.347 views
OpenERP e l'arte della gestione aziendale con Python by PyCon Italia
OpenERP e l'arte della gestione aziendale con PythonOpenERP e l'arte della gestione aziendale con Python
OpenERP e l'arte della gestione aziendale con Python
PyCon Italia919 views
Fpga 06-data-types-system-tasks-compiler-directives by Malik Tauqir Hasan
Fpga 06-data-types-system-tasks-compiler-directivesFpga 06-data-types-system-tasks-compiler-directives
Fpga 06-data-types-system-tasks-compiler-directives
Hello, Is That FreeSWITCH? Then We're Coming to Check You! by PVS-Studio
Hello, Is That FreeSWITCH? Then We're Coming to Check You!Hello, Is That FreeSWITCH? Then We're Coming to Check You!
Hello, Is That FreeSWITCH? Then We're Coming to Check You!
PVS-Studio203 views
Benchmarking Perl (Chicago UniForum 2006) by brian d foy
Benchmarking Perl (Chicago UniForum 2006)Benchmarking Perl (Chicago UniForum 2006)
Benchmarking Perl (Chicago UniForum 2006)
brian d foy2.4K views
Set Up & Operate Tungsten Replicator by Continuent
Set Up & Operate Tungsten ReplicatorSet Up & Operate Tungsten Replicator
Set Up & Operate Tungsten Replicator
Continuent655 views
Container Orchestration from Theory to Practice by Docker, Inc.
Container Orchestration from Theory to PracticeContainer Orchestration from Theory to Practice
Container Orchestration from Theory to Practice
Docker, Inc.1.6K views

Recently uploaded

Introduction to Gradle by
Introduction to GradleIntroduction to Gradle
Introduction to GradleJohn Valentino
6 views7 slides
Electronic AWB - Electronic Air Waybill by
Electronic AWB - Electronic Air Waybill Electronic AWB - Electronic Air Waybill
Electronic AWB - Electronic Air Waybill Freightoscope
5 views1 slide
Agile 101 by
Agile 101Agile 101
Agile 101John Valentino
12 views20 slides
Bootstrapping vs Venture Capital.pptx by
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptxZeljko Svedic
15 views17 slides
predicting-m3-devopsconMunich-2023-v2.pptx by
predicting-m3-devopsconMunich-2023-v2.pptxpredicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptxTier1 app
12 views33 slides
tecnologia18.docx by
tecnologia18.docxtecnologia18.docx
tecnologia18.docxnosi6702
5 views5 slides

Recently uploaded(20)

Electronic AWB - Electronic Air Waybill by Freightoscope
Electronic AWB - Electronic Air Waybill Electronic AWB - Electronic Air Waybill
Electronic AWB - Electronic Air Waybill
Freightoscope 5 views
Bootstrapping vs Venture Capital.pptx by Zeljko Svedic
Bootstrapping vs Venture Capital.pptxBootstrapping vs Venture Capital.pptx
Bootstrapping vs Venture Capital.pptx
Zeljko Svedic15 views
predicting-m3-devopsconMunich-2023-v2.pptx by Tier1 app
predicting-m3-devopsconMunich-2023-v2.pptxpredicting-m3-devopsconMunich-2023-v2.pptx
predicting-m3-devopsconMunich-2023-v2.pptx
Tier1 app12 views
tecnologia18.docx by nosi6702
tecnologia18.docxtecnologia18.docx
tecnologia18.docx
nosi67025 views
Automated Testing of Microsoft Power BI Reports by RTTS
Automated Testing of Microsoft Power BI ReportsAutomated Testing of Microsoft Power BI Reports
Automated Testing of Microsoft Power BI Reports
RTTS10 views
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium... by Lisi Hocke
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Team Transformation Tactics for Holistic Testing and Quality (Japan Symposium...
Lisi Hocke35 views
predicting-m3-devopsconMunich-2023.pptx by Tier1 app
predicting-m3-devopsconMunich-2023.pptxpredicting-m3-devopsconMunich-2023.pptx
predicting-m3-devopsconMunich-2023.pptx
Tier1 app8 views
Top-5-production-devconMunich-2023-v2.pptx by Tier1 app
Top-5-production-devconMunich-2023-v2.pptxTop-5-production-devconMunich-2023-v2.pptx
Top-5-production-devconMunich-2023-v2.pptx
Tier1 app8 views
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile... by Stefan Wolpers
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...
How To Make Your Plans Suck Less — Maarten Dalmijn at the 57th Hands-on Agile...
Stefan Wolpers42 views
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated... by TomHalpin9
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
Dev-HRE-Ops - Addressing the _Last Mile DevOps Challenge_ in Highly Regulated...
TomHalpin96 views
Introduction to Git Source Control by John Valentino
Introduction to Git Source ControlIntroduction to Git Source Control
Introduction to Git Source Control
John Valentino7 views
Airline Booking Software by SharmiMehta
Airline Booking SoftwareAirline Booking Software
Airline Booking Software
SharmiMehta9 views
How to build dyanmic dashboards and ensure they always work by Wiiisdom
How to build dyanmic dashboards and ensure they always workHow to build dyanmic dashboards and ensure they always work
How to build dyanmic dashboards and ensure they always work
Wiiisdom14 views
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P... by NimaTorabi2
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
Unlocking the Power of AI in Product Management - A Comprehensive Guide for P...
NimaTorabi216 views
FOSSLight Community Day 2023-11-30 by Shane Coughlan
FOSSLight Community Day 2023-11-30FOSSLight Community Day 2023-11-30
FOSSLight Community Day 2023-11-30
Shane Coughlan7 views

Oracle Inter-Session Communication

  • 1. Oracle Inter-Session Communication Oren Nakdimon www.db-oriented.com  oren@db-oriented.com  +972-54-4393763 @DBoriented
  • 2. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon http://db-oriented.com Who Am I?
  • 4. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session Session Session
  • 5. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session Session Session
  • 6. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session SGA Session Session
  • 7. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session SGA Session Session
  • 8. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session Outbox SGA Inbox Session Session Outbox Inbox Outbox Inbox
  • 9. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session Outbox SGA Inbox Session Session Outbox Inbox Outbox Inbox
  • 10. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session Outbox SGA Inbox Session Session Outbox Inbox Outbox Inbox
  • 11. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session Outbox SGA Session Outbox Inbox Session Inbox Outbox Inbox Outbox
  • 12. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session Outbox SGA Session Outbox Inbox Session Inbox Outbox Inbox Outbox Inbox
  • 13. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session Session Outbox SGA Session Outbox Inbox Inbox Outbox Outbox Outbox Inbox
  • 14. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session Session Outbox SGA Session Outbox Inbox Inbox Outbox Outbox Outbox Inbox
  • 15. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session Session Outbox SGA Session Outbox Inbox Inbox Outbox Outbox Outbox Inbox
  • 17. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package pipe_demo as procedure log(i_text in varchar2); procedure get_next ( o_user out varchar2, o_sid out number, o_host out varchar2, o_time out date, o_text out varchar2 ); end pipe_demo;
  • 18. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package pipe_demo as procedure log(i_text in varchar2); procedure get_next ( o_user out varchar2, o_sid out number, o_host out varchar2, o_time out date, o_text out varchar2 ); end pipe_demo;
  • 19. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package pipe_demo as procedure log(i_text in varchar2); procedure get_next ( o_user out varchar2, o_sid out number, o_host out varchar2, o_time out date, o_text out varchar2 ); end pipe_demo;
  • 20. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package body pipe_demo as c_log_pipe constant varchar2(13) := 'DEMO_LOG_PIPE'; procedure log(i_text in varchar2) is l_status number; begin dbms_pipe.pack_message(user); dbms_pipe.pack_message(to_number(sys_context('userenv', 'sid'))); dbms_pipe.pack_message(sys_context('userenv', 'host')); dbms_pipe.pack_message(sysdate); dbms_pipe.pack_message(i_text); l_status := dbms_pipe.send_message(c_log_pipe); if l_status != 0 then raise_application_error(-20000, 'dbms_pipe.send_message failed with status ' || l_status); end if; end log;
  • 21. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package body pipe_demo as c_log_pipe constant varchar2(13) := 'DEMO_LOG_PIPE'; procedure log(i_text in varchar2) is l_status number; begin dbms_pipe.pack_message(user); dbms_pipe.pack_message(to_number(sys_context('userenv', 'sid'))); dbms_pipe.pack_message(sys_context('userenv', 'host')); dbms_pipe.pack_message(sysdate); dbms_pipe.pack_message(i_text); l_status := dbms_pipe.send_message(c_log_pipe); if l_status != 0 then raise_application_error(-20000, 'dbms_pipe.send_message failed with status ' || l_status); end if; end log;
  • 22. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package body pipe_demo as c_log_pipe constant varchar2(13) := 'DEMO_LOG_PIPE'; procedure log(i_text in varchar2) is l_status number; begin dbms_pipe.pack_message(user); dbms_pipe.pack_message(to_number(sys_context('userenv', 'sid'))); dbms_pipe.pack_message(sys_context('userenv', 'host')); dbms_pipe.pack_message(sysdate); dbms_pipe.pack_message(i_text); l_status := dbms_pipe.send_message(c_log_pipe); if l_status != 0 then raise_application_error(-20000, 'dbms_pipe.send_message failed with status ' || l_status); end if; end log;
  • 23. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package body pipe_demo as c_log_pipe constant varchar2(13) := 'DEMO_LOG_PIPE'; procedure log(i_text in varchar2) is l_status number; begin dbms_pipe.pack_message(user); dbms_pipe.pack_message(to_number(sys_context('userenv', 'sid'))); dbms_pipe.pack_message(sys_context('userenv', 'host')); dbms_pipe.pack_message(sysdate); dbms_pipe.pack_message(i_text); l_status := dbms_pipe.send_message(c_log_pipe); if l_status != 0 then raise_application_error(-20000, 'dbms_pipe.send_message failed with status ' || l_status); end if; end log; pack_message (number) pack_message (varchar2) pack_message (date) pack_message_raw pack_message_rowid
  • 24. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package body pipe_demo as c_log_pipe constant varchar2(13) := 'DEMO_LOG_PIPE'; procedure log(i_text in varchar2) is l_status number; begin dbms_pipe.pack_message(user); dbms_pipe.pack_message(to_number(sys_context('userenv', 'sid'))); dbms_pipe.pack_message(sys_context('userenv', 'host')); dbms_pipe.pack_message(sysdate); dbms_pipe.pack_message(i_text); l_status := dbms_pipe.send_message(c_log_pipe); if l_status != 0 then raise_application_error(-20000, 'dbms_pipe.send_message failed with status ' || l_status); end if; end log;
  • 25. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon procedure get_next ( o_user out varchar2, o_sid out number, o_host out varchar2, o_time out date, o_text out varchar2 ) is l_status number; begin l_status := dbms_pipe.receive_message(pipename => c_log_pipe); if l_status != 0 then raise_application_error(-20000, 'dbms_pipe.receive_message failed with status ' || l_status); end if; dbms_pipe.unpack_message(o_user); dbms_pipe.unpack_message(o_sid); dbms_pipe.unpack_message(o_host); dbms_pipe.unpack_message(o_time); dbms_pipe.unpack_message(o_text); end get_next; end pipe_demo;
  • 26. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon procedure get_next ( o_user out varchar2, o_sid out number, o_host out varchar2, o_time out date, o_text out varchar2 ) is l_status number; begin l_status := dbms_pipe.receive_message(pipename => c_log_pipe); if l_status != 0 then raise_application_error(-20000, 'dbms_pipe.receive_message failed with status ' || l_status); end if; dbms_pipe.unpack_message(o_user); dbms_pipe.unpack_message(o_sid); dbms_pipe.unpack_message(o_host); dbms_pipe.unpack_message(o_time); dbms_pipe.unpack_message(o_text); end get_next; end pipe_demo;
  • 27. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon procedure get_next ( o_user out varchar2, o_sid out number, o_host out varchar2, o_time out date, o_text out varchar2 ) is l_status number; begin l_status := dbms_pipe.receive_message(pipename => c_log_pipe); if l_status != 0 then raise_application_error(-20000, 'dbms_pipe.receive_message failed with status ' || l_status); end if; dbms_pipe.unpack_message(o_user); dbms_pipe.unpack_message(o_sid); dbms_pipe.unpack_message(o_host); dbms_pipe.unpack_message(o_time); dbms_pipe.unpack_message(o_text); end get_next; end pipe_demo; unpack_message (number) unpack_message (varchar2) unpack_message (date) unpack_message_raw unpack_message_rowid
  • 28. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon public class Logger { public static void main(String args[]) throws SQLException { Properties info = new Properties(); info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER); info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD); OracleDataSource ods = new OracleDataSource(); ods.setURL(DB_URL); ods.setConnectionProperties(info); try (OracleConnection connection = (OracleConnection) ods.getConnection()) { DatabaseMetaData dbmd = connection.getMetaData(); System.out.println("Ready..."); System.out.println(); System.out.println("Time Host User SID Message"); System.out.println("--------------- -------------- ----- --- -------"); processRequests(connection); System.out.println("Bye!"); System.out.println(); } }
  • 29. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon public class Logger { public static void main(String args[]) throws SQLException { Properties info = new Properties(); info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER); info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD); OracleDataSource ods = new OracleDataSource(); ods.setURL(DB_URL); ods.setConnectionProperties(info); try (OracleConnection connection = (OracleConnection) ods.getConnection()) { DatabaseMetaData dbmd = connection.getMetaData(); System.out.println("Ready..."); System.out.println(); System.out.println("Time Host User SID Message"); System.out.println("--------------- -------------- ----- --- -------"); processRequests(connection); System.out.println("Bye!"); System.out.println(); } }
  • 30. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon public class Logger { public static void main(String args[]) throws SQLException { Properties info = new Properties(); info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER); info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD); OracleDataSource ods = new OracleDataSource(); ods.setURL(DB_URL); ods.setConnectionProperties(info); try (OracleConnection connection = (OracleConnection) ods.getConnection()) { DatabaseMetaData dbmd = connection.getMetaData(); System.out.println("Ready..."); System.out.println(); System.out.println("Time Host User SID Message"); System.out.println("--------------- -------------- ----- --- -------"); processRequests(connection); System.out.println("Bye!"); System.out.println(); } }
  • 31. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon public class Logger { public static void main(String args[]) throws SQLException { Properties info = new Properties(); info.put(OracleConnection.CONNECTION_PROPERTY_USER_NAME, DB_USER); info.put(OracleConnection.CONNECTION_PROPERTY_PASSWORD, DB_PASSWORD); OracleDataSource ods = new OracleDataSource(); ods.setURL(DB_URL); ods.setConnectionProperties(info); try (OracleConnection connection = (OracleConnection) ods.getConnection()) { DatabaseMetaData dbmd = connection.getMetaData(); System.out.println("Ready..."); System.out.println(); System.out.println("Time Host User SID Message"); System.out.println("--------------- -------------- ----- --- -------"); processRequests(connection); System.out.println("Bye!"); System.out.println(); } }
  • 32. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon public static void processRequests(Connection connection) throws SQLException { String user; int sid; String host; Timestamp time; String text = " "; CallableStatement callableStatement = connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }"); callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(2, java.sql.Types.INTEGER); callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(4, java.sql.Types.DATE); callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR); do { callableStatement.executeUpdate(); user = callableStatement.getString(1); sid = callableStatement.getInt(2); host = callableStatement.getString(3); time = callableStatement.getTimestamp(4); text = callableStatement.getString(5); System.out.println(time + " " + host + " " + user + " " + String.format("%3s",
  • 33. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon public static void processRequests(Connection connection) throws SQLException { String user; int sid; String host; Timestamp time; String text = " "; CallableStatement callableStatement = connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }"); callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(2, java.sql.Types.INTEGER); callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(4, java.sql.Types.DATE); callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR); do { callableStatement.executeUpdate(); user = callableStatement.getString(1); sid = callableStatement.getInt(2); host = callableStatement.getString(3); time = callableStatement.getTimestamp(4); text = callableStatement.getString(5); System.out.println(time + " " + host + " " + user + " " + String.format("%3s",
  • 34. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon public static void processRequests(Connection connection) throws SQLException { String user; int sid; String host; Timestamp time; String text = " "; CallableStatement callableStatement = connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }"); callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(2, java.sql.Types.INTEGER); callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(4, java.sql.Types.DATE); callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR); do { callableStatement.executeUpdate(); user = callableStatement.getString(1); sid = callableStatement.getInt(2); host = callableStatement.getString(3); time = callableStatement.getTimestamp(4); text = callableStatement.getString(5); System.out.println(time + " " + host + " " + user + " " + String.format("%3s",
  • 35. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon CallableStatement callableStatement = connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }"); callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(2, java.sql.Types.INTEGER); callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(4, java.sql.Types.DATE); callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR); do { callableStatement.executeUpdate(); user = callableStatement.getString(1); sid = callableStatement.getInt(2); host = callableStatement.getString(3); time = callableStatement.getTimestamp(4); text = callableStatement.getString(5); System.out.println(time + " " + host + " " + user + " " + String.format("%3s", sid) + " " + text); } while (!text.equals("ABORT")); callableStatement.close(); } }
  • 36. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon CallableStatement callableStatement = connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }"); callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(2, java.sql.Types.INTEGER); callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(4, java.sql.Types.DATE); callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR); do { callableStatement.executeUpdate(); user = callableStatement.getString(1); sid = callableStatement.getInt(2); host = callableStatement.getString(3); time = callableStatement.getTimestamp(4); text = callableStatement.getString(5); System.out.println(time + " " + host + " " + user + " " + String.format("%3s", sid) + " " + text); } while (!text.equals("ABORT")); callableStatement.close(); } }
  • 37. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon CallableStatement callableStatement = connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }"); callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(2, java.sql.Types.INTEGER); callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(4, java.sql.Types.DATE); callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR); do { callableStatement.executeUpdate(); user = callableStatement.getString(1); sid = callableStatement.getInt(2); host = callableStatement.getString(3); time = callableStatement.getTimestamp(4); text = callableStatement.getString(5); System.out.println(time + " " + host + " " + user + " " + String.format("%3s", sid) + " " + text); } while (!text.equals("ABORT")); callableStatement.close(); } }
  • 38. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon CallableStatement callableStatement = connection.prepareCall("{ call PIPE_DEMO.GET_NEXT(?,?,?,?,?) }"); callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(2, java.sql.Types.INTEGER); callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR); callableStatement.registerOutParameter(4, java.sql.Types.DATE); callableStatement.registerOutParameter(5, java.sql.Types.VARCHAR); do { callableStatement.executeUpdate(); user = callableStatement.getString(1); sid = callableStatement.getInt(2); host = callableStatement.getString(3); time = callableStatement.getTimestamp(4); text = callableStatement.getString(5); System.out.println(time + " " + host + " " + user + " " + String.format("%3s", sid) + " " + text); } while (!text.equals("ABORT")); callableStatement.close(); } }
  • 40. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon SGA Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox
  • 41. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon SGA Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox
  • 42. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon SGA Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox
  • 44. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon SGA Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox
  • 46. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon
  • 47. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package pipe_demo as procedure log(i_text in varchar2); procedure get_next ( o_user out varchar2, o_sid out number, o_host out varchar2, o_time out date, o_text out varchar2 ); procedure send_many_logs ( i_text in varchar2, i_how_many in binary_integer ); end pipe_demo;
  • 48. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package body pipe_demo as ... procedure send_many_logs ( i_text in varchar2, i_how_many in binary_integer ) is c_alert_name constant varchar2(10) := 'DEMO_ALERT'; l_message varchar2(100); l_status number; begin dbms_alert.register(c_alert_name); dbms_alert.waitone(c_alert_name, l_message, l_status); for i in 1 .. i_how_many loop pipe_demo.log(i_text || '# ' || to_char(i)); end loop; dbms_alert.remove(c_alert_name); end send_many_logs; end pipe_demo;
  • 49. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package body pipe_demo as ... procedure send_many_logs ( i_text in varchar2, i_how_many in binary_integer ) is c_alert_name constant varchar2(10) := 'DEMO_ALERT'; l_message varchar2(100); l_status number; begin dbms_alert.register(c_alert_name); dbms_alert.waitone(c_alert_name, l_message, l_status); for i in 1 .. i_how_many loop pipe_demo.log(i_text || '# ' || to_char(i)); end loop; dbms_alert.remove(c_alert_name); end send_many_logs; end pipe_demo;
  • 51. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon Session Session Session Session Session Session
  • 52. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package body pipe_demo as ... procedure send_many_logs ( i_text in varchar2, i_how_many in binary_integer ) is c_alert_name constant varchar2(10) := 'DEMO_ALERT'; l_message varchar2(100); l_status number; begin dbms_alert.register(c_alert_name); dbms_alert.waitone(c_alert_name, l_message, l_status); for i in 1 .. i_how_many loop pipe_demo.log(i_text || '# ' || to_char(i)); end loop; dbms_alert.remove(c_alert_name); end send_many_logs; end pipe_demo;
  • 53. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package body pipe_demo as ... procedure send_many_logs ( i_text in varchar2, i_how_many in binary_integer ) is c_alert_name constant varchar2(10) := 'DEMO_ALERT'; l_message varchar2(100); l_status number; begin dbms_alert.register(c_alert_name); dbms_alert.waitone(c_alert_name, l_message, l_status); for i in 1 .. i_how_many loop pipe_demo.log(i_text || '# ' || to_char(i)); end loop; dbms_alert.remove(c_alert_name); end send_many_logs; end pipe_demo;
  • 54. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package body pipe_demo as ... procedure send_many_logs ( i_text in varchar2, i_how_many in binary_integer ) is c_alert_name constant varchar2(10) := 'DEMO_ALERT'; l_message varchar2(100); l_status number; begin dbms_alert.register(c_alert_name); dbms_alert.waitone(c_alert_name, l_message, l_status); for i in 1 .. i_how_many loop pipe_demo.log(i_text || '# ' || to_char(i)); end loop; dbms_alert.remove(c_alert_name); end send_many_logs; end pipe_demo; There is also dbms_alert.waitany
  • 55. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon create or replace package body pipe_demo as ... procedure send_many_logs ( i_text in varchar2, i_how_many in binary_integer ) is c_alert_name constant varchar2(10) := 'DEMO_ALERT'; l_message varchar2(100); l_status number; begin dbms_alert.register(c_alert_name); dbms_alert.waitone(c_alert_name, l_message, l_status); for i in 1 .. i_how_many loop pipe_demo.log(i_text || '# ' || to_char(i)); end loop; dbms_alert.remove(c_alert_name); end send_many_logs; end pipe_demo; There is also dbms_alert.removeall
  • 57. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon SGA Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox
  • 58. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon SGA Session Inbox Outbox Session Inbox Outbox Session Inbox Outbox dbms_pipe.unique_session_name
  • 59. This presentation is available in http://db-oriented.com/presentations © Oren Nakdimon © Oren Nakdimon DBMS_PIPE DBMS_ALERT Type Named Pipes / Queue Signals / Broadcast Implementation SGA structure Table Transactional? Non-Transactional Transactional Consumers of a specific message Single Consumer Zero-to-Multiple Consumers Blocked Publisher? When pipe is full (“pipe put” wait event) When other session signaled to the same alert and hasn’t committed yet (TX lock), but only if there are registered consumers Possible Loss of Messages? Instance crash/shutdown Multiple signals to the same alert before read by the consumer
  • 60. THANK YOU Oren Nakdimon www.db-oriented.com  oren@db-oriented.com  +972-54-4393763 @DBoriented