Rem
Rem $Header: mq_adm_cleanup.sql 11-jul-2003.15:49:19 kbittler Exp $
Rem
Rem mq_adm_cleanup.sql
Rem
Rem Copyright (c) 2003, Oracle Corporation.  All rights reserved.
Rem
Rem    NAME
Rem      mq_adm_cleanup.sql - Removes the Messaging Gateway configuration.
Rem
Rem    DESCRIPTION
Rem      Script to remove Messaging Gateway configured objects used in this
Rem      this sample.
Rem
Rem    NOTES
Rem      WARNING!! This script should be run when the Messaging Gateway agent is
Rem      running.  If the agent is not running, the subscriber will not be fully
Rem      removed until the agent is restarted.
Rem      The order of removing objects is important.
Rem      A link cannot be removed until all associated foreign queues have been
Rem      unregistered.  A foreign queue cannot be unregistered when subscribers
Rem      or schedules reference it.
Rem

connect mqadmin/mqadmin

Rem Remove the subscribers.
begin
  -- Since this subscriber was for outbound propagation
  -- removing it will remove the underlying AQ subscriber.
  dbms_mgwadm.remove_subscriber(subscriber_id => 'sub_aq2mq', force  => dbms_mgwadm.FORCE);
end;
/

Rem Remove the schedules.
begin
  dbms_mgwadm.unschedule_propagation(schedule_id => 'sch_aq2mq');
end;
/

Rem Unregister the MQSeries queue.
begin
  dbms_mgwadm.unregister_foreign_queue(name => 'destq', linkname => 'mqlink');
end;
/

Rem Finally, remove the link.
begin
  dbms_mgwadm.remove_msgsystem_link('mqlink');
end;
/